[英]Codeigniter Active Record - where time from timestamp is greater than
I am trying to compare the time from a timestamp with the current time. 我正在尝试将时间戳的时间与当前时间进行比较。
I currently have the following line: 我目前有以下一行:
$this->db->where('period_end >', $time);
But this compares 1995-04-08 13:00:00
against 10:43:44
但这与
1995-04-08 13:00:00
和10:43:44
What i want to compare is 13:00:00
against 10:43:44
and ignore the date completely. 我要比较的是
13:00:00
对10:43:44
,完全忽略了日期。
Any ideas? 有任何想法吗?
You can compare the time part from datatime field by using DATE_FORMAT
,Also using this approach you need to pass third parameter as FALSE
to avoid addition of backticks by active record 您可以使用
DATE_FORMAT
来比较datatime字段中的时间部分,此外,使用此方法时,您需要将第三个参数作为FALSE
传递,以避免活动记录添加反引号
$this->db->where("DATE_FORMAT(period_end,'%H:%i:%s') >", $time,FALSE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.