本文实例讲述了yii2实现根据时间搜索的方法。分享给大家供大家参考,具体如下://datetosea
本文实例讲述了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]);
yii2
时间
搜索