Php 数据库时间数据检索,基于时间的查询

Php 数据库时间数据检索,基于时间的查询,php,mysql,database,time,Php,Mysql,Database,Time,我不熟悉时间操作或时间算术运算 我目前正在开发一个基于Web服务器的信息导航系统,目前我有一个数据库,其中包含一个表peek hours,其列为id、start\u time、end\u time、edge\u id、day\u of the_week、edge\u weight ------------------------------------------------------------------------ | Peek Hours

我不熟悉时间操作或时间算术运算 我目前正在开发一个基于Web服务器的信息导航系统,目前我有一个数据库,其中包含一个表peek hours,其列为id、start\u time、end\u time、edge\u id、day\u of the_week、edge\u weight

 ------------------------------------------------------------------------
|                  Peek Hours                                           |
 ------------------------------------------------------------------------
|    |            |           |         |                 |             |
| id | start_time |  end_time | edge_id | day_of_the_week | edge_weight |
|    |            |           |         |                 |             |
 ------------------------------------------------------------------------
我使用PHP作为Web服务,因此根据当前时间,我希望获得符合此等式的所有记录


start\u time

正如其他评论所暗示的那样,您看起来并不太努力

 SELECT *
 FROM peek_hours
 WHERE start_time < NOW()
 AND NOW() < end_time

虽然BETWEEN是“小于或等于”。

您对SQL有问题吗?在任何情况下,您都需要一个带有
WHERE
子句的
SELECT
语句;-)你必须观察
current\u time
的格式,我想你是从你的脚本中得到的,还有
start\u time
,分别是
end\u time
。PHP和MySQL都内置了格式化日期、时间和日期时间的功能。
 SELECT *
 FROM peek_hours
 WHERE NOW() between start_time AND end_time