如何检查两个时间戳PHP之间的差异

时间:2019-07-24 08:07:01

标签: php mysql datetime timestamp

我有数据库名称“ shop_booking”,我有两列(start_time,end_time,数据类型为int(11)),我将值存储为时间戳(unix_timestamp),现在我想传递两个参数(动态)以了解是否商店是否已预订(我发送的时间,是否与现有时间匹配),但未显示正确的数据

这是我的桌子“预订”

id        shop_id         start_time                                       end_time
1         3               1563960849 (showing 7/24/2019,3:04:09PM)         1563964449 (showing 7/24/2019,4:04:09 PM) 
2         3               1563946449 (showing 7/24/2019,11:04:09 AM)       1563950049 (showing 7/24/2019,12:04:09 PM) 

我尝试了以下查询,但不起作用,如果数据库中的starttime(动态)和end_time(动态)与start和end_time匹配,我想获取记录吗?我怎样才能做到这一点 ?我哪里错了?这是我的代码

$st="1563962100"; //for testing right now using static timestamp
$en="1563967800";
$query=$this->db->query("SELECT `id`  FROM `booking` WHERE ( `tstart_time` <= CAST('$st' AS TIME)  AND `end_time` >= CAST('$en' AS TIME) )");

0 个答案:

没有答案