Home > Backend Development > PHP Tutorial > yii2 implements search method based on time, yii2 implements search_PHP tutorial

yii2 implements search method based on time, yii2 implements search_PHP tutorial

WBOY
Release: 2016-07-12 08:50:41
Original
1057 people have browsed it

yii2 implements search based on time, yii2 implements search

The example in this article describes the method of yii2 implementing search based on time. Share it with everyone for your reference, the details are as follows:

// 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]);

Copy after login

Readers who are interested in more Yii-related content can check out the special topics on this site: "Introduction to Yii Framework and Summary of Common Techniques", "Summary of Excellent PHP Development Framework", "Basic Tutorial for Getting Started with Smarty Templates", "php Date and Time" Usage Summary", "php object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1133086.htmlTechArticleYii2 implements search based on time, yii2 implements search. This article describes the example of yii2 implementing time based search. Share it with everyone for your reference, the details are as follows: // date to se...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template