我如何将时间与今天的日期进行比较?

时间:2017-02-10 08:50:48

标签: php mysql yii2

我正在尝试将Yii2中的datetimetime进行比较,同时使用今天的日期作为基础。我已经到了这一行,但我很确定这不是正确的方法(并且不起作用):

$items = mtype::find()->select(["id"])->where(["<","last_run","from_unixtime(unix_timestamp(curdate())+unix_timestamp(concat('1970-01-01 ',time_format(curtime(),'%H:%i:00'))))"])->asArray()->all();

1 个答案:

答案 0 :(得分:0)

如果我理解正确,您想要选择last_run的时间早于当前时间的行。

如果是这样,您可以执行以下操作:

SELECT id
FROM xxx
WHERE TIME(last_run) < CURTIME();

https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html告诉您有关日期/时间功能的任何信息;)

相关问题