我有一个通过 PHPmyadmin 创建的数据库。我对时间列/计算有疑问。
table name = course
..course_name | section_ID | Dr_ID | time_start | time_end | location
...................................| 10:00:00 | 10:20:00 < //i but the
value like this
以及 (| time_start | time_end |) = Time
的类型/就像 PHPmyadmin 中的这样
我的查询不起作用。我猜问题是.time()。在查询中:
$query2 = "SELECT location FROM sections where Dr_ID = 1
AND time_start <= ".time()." and time_end > ".time();
最佳答案
time()
函数返回一个unix时间戳,您的*time_start*字段似乎是mysql TIME类型,您需要转换其中之一才能进行正确的比较。
您可以使用date("H:i:s",time())
代替time()
,这可能会得到您想要的
或者您需要将 *time_start* *time_end* 字段转换为 unix 时间戳 UNIX_TIMESTAMP() - 您需要将日期连接到 *time_start* 前面。
关于php - 我怎样才能在mysql查询中获取当前时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6420375/