如何从(00:00)的mysql数据库中显示小时和分钟只有Php? 这是我的代码:
$query = "SELECT * FROM table";
$resualt = mysqli_query($conn, $query);
if (mysqli_num_rows($resualt) > 0)
{
echo "<table class='tb'>";
while($row = mysqli_fetch_assoc($resualt)){
echo "<tr><td>" . $row['id']. "</td><td> " .$row['name']. " </td><td> " . $row['place']. " </td><td> " . $row['ddate']. " </td><td> " . $row['dtime']. " </td><td> ".$row['message']."</td></tr>";
}
echo `enter code here`"<table>";
}
else
{
echo "there is no record.";
}
感谢
答案 0 :(得分:2)
您通过MySQL查询时间
SELECT DATE_FORMAT(NOW(), '%H:%i')
例如
$query = "SELECT *, DATE_FORMAT(NOW(), '%H:%i') as time FROM table";
然后您可以通过$row['time'];
答案 1 :(得分:0)
假设你的桌子有一个日期时间栏,你可以像这样从中抽取小时和分钟......
SELECT HOUR( `datecol` ) AS HOUR, MINUTE( `datecol` ) AS MINUTE FROM table WHERE BLAH=blah
您还可以选择其他内容,例如....
WEEK
获取一年中的周数
WEEKDAY
获取本周的日期名称...