MySQL比较时间(datetime)大小

获取时间返回的秒数:strtotime('2019-05-10 00:00:00')

遇到一个业务功能需要将当前时间与数据库中的会议开始、结束时间进行比较,记录一下,方便下次用。

用unix_timestamp函数,将字符型的时间,转成unix时间戳。

select meeting_id,meeting_name,start_time,end_time from meeting_data
where meeting_id REGEXP '[0-9]{4}0001'
and unix_timestamp(start_time) < unix_timestamp(NOW())
and unix_timestamp(end_time) > unix_timestamp(NOW());
------------------------------------------------------------------------------------------------

原文:https://blog.csdn.net/qq_27124771/article/details/81219550

posted @ 2019-05-10 10:50  橱窗外的小孩  阅读(30235)  评论(0编辑  收藏  举报