yii2实现根据时间搜索的方法
本文实例讲述了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实现根据时间搜索的方法。分享给大家供大家参考,具体如下:
// 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]);
扫码二维码 获取免费视频学习资料
- 本文固定链接: http://www.phpxs.com/post/7055/
- 转载请注明:转载必须在正文中标注并保留原文链接
- 扫码: 扫上方二维码获取免费视频资料
查 看2022高级编程视频教程免费获取