将mysql datetime更改为php datetime-local不能通过strtotime()工作 [英] change mysql datetime to php datetime-local not working by strtotime()
本文介绍了将mysql datetime更改为php datetime-local不能通过strtotime()工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有数据时间类型的mysql表,我希望它在php / html表中显示
I have mysql table with datatime type and i want it to show in php/html table
while($row = mysqli_fetch_assoc($result)) {
$time1 = strtotime($row["Request Date"]);
$myFormatForView = date("d/m/y g:i A", $time1);
输出
11/02/15 10:18 AM
现在我尝试使用此代码html表
now i tried this code to work with html table
<td> <input type='datetime-local' id='txt_dateid_".$i."' value=".$myFormatForView." disabled></td>
但我没有得到任何输出
完整代码
<?php
include_once "connector.php";
$sql = "SELECT * FROM $tablename";
$result = mysqli_query($db,$sql);
$i=0;
$row=0;
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$time1 = strtotime($row["Request Date"]);
$myFormatForView = date("d/m/y g:i A", $time1);
echo ($myFormatForView);
echo
"
<tr>
<td size='20' align='center'> <input type='text' id='txt_orderid_".$i."'value=" . $row["Order ID"]. " disabled> </td>
<td> <button type='button' id='btn_update_".$i."' onclick='myFunction($i)'>update</button> </td>
<td> <button type='button' id='btn_delete_".$i."' onclick='DeleteFunction($i)'>delete</button> </td>
<td> <input type='datetime-local' id='txt_dateid_".$i."'value=" . $myFormatForView. " disabled></td>
<td> <input type='text' id='txt_timeid_".$i."'class='txt_id_".$i."' value=" . $row["Fixed Time"]. " disabled></td>
<td> <input type='text' id='txt_toolid_".$i."' class='txt_id_".$i."' value=" . $row["Tool"]. " disabled> </td>
<td> <input type='text' id='txt_nameid_".$i."' class='txt_id_".$i."' value=" . $row["Name"]. " disabled> </td>
<td> <input type='text' id='txt_emailid_".$i."' class='txt_id_".$i."' value=" . $row["Email"]. " disabled> </td>
<td> <input type='text' id='txt_countid_".$i."' class='txt_id_".$i."' value=" . $row["Country Entered"]. " disabled> </td>
</tr>
";
$i++;
}
编辑1:
此代码也不起作用
<td> <input type='datetime-local' id='txt_dateid_".$i."' 'value'=".$myFormatForView." disabled></td>
编辑2:
推荐答案
您错过了value属性的引用。试试这个:
You have missed the quotes for value attribute. Try this:
<td> <input type='datetime-local' id='txt_dateid_".$i."' value='".$myFormatForView."' disabled></td>
这篇关于将mysql datetime更改为php datetime-local不能通过strtotime()工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文