本文实例讲述了yii2实现根据时间搜索的方法。分享给大家供大家参考,具体如下:
// date to search
$date = DateTime::createFromFormat('m/d/Y', '10/27/2014');
$date->setTime(0,0,0);
// set lowest date value
$unixDateStart = $date->getTimeStamp();
// add 1 day and subtract 1 second
$date->add(new DateInterval('P1D'));
$date->sub(new DateInterval('PT1S'));
// set highest date value
$unixDateEnd = $date->getTimeStamp();
$query->andFilterWhere(
['between', 'created_at', $unixDateStart, $unixDateEnd]);
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
2025国考·省考课程试听报名