获取时间返回的秒数:strtotime(‘2019-05-10 00:00:00’)
当我们遇到查询业务功能时,需要查询开始时间到结束时间区间的数据,这里就需要比较时间大小
用unix_timestamp函数,将字符型的时间,转成unix时间戳。
select id,name,create_time from tabledata
where unix_timestamp(start_time) < unix_timestamp(create_time)
and unix_timestamp(end_time) > unix_timestamp(create_time);
当需要大于等于小于等于的时候可能需要转义符号
<![CDATA[ AND t.illegal_time<UNIX_TIMESTAMP(#{endDate})*1000]]>