从日期和时间字段php mysql 15分钟后显示结果

时间:2017-11-08 04:26:22

标签: php mysql

我正在预订网站。我预订了date_createdtime_created字段的表格。我将今天的日期存储为date_created,将当前时间存储为time_created。我想在管理面板中time_created的15分钟后列出预订。如何做到这一点?

我试过了这个问题。

SELECT *
FROM tbl_booking
WHERE (date_created = '$todaysdt'
       AND time_created >= '$timenow')
  OR (date_created < '$todaysdt')
ORDER BY booking_id DESC

但这不起作用。任何帮助将不胜感激。提前谢谢。

2 个答案:

答案 0 :(得分:0)

试一试:

select *
from tbl_booking
where STR_TO_DATE(concat_ws(date_created," ",time_created),"%Y-%m-%d %H:%i") < DATE_SUB(NOW(), INTERVAL 15 MINUTE)
order by booking_id desc

答案 1 :(得分:0)

我想你可能需要这个:更新

select * from tbl_booking where (date_created = CURDATE() AND time_created <= time(DATE_SUB(NOW(), INTERVAL 15 MINUTE))) OR (date_created < CURDATE()) order by booking_id desc