How does php query this year's data?
Editor to share with you how php query this year's data, I hope you will learn something after reading this article, let's discuss it together!
Php query this year's data: 1, obtain the current year's time through date; 2, run the query statement "$result = $db- > where ($where)-> select ();".
This article operating environment: Windows7 system, thinkphp v5.1, Dell G3 computer.
Thinkphp inquires the data of that day, this week, this month and this year.
Codes such as:
/ / time of the day $where ['time'] = array (array (' egt',strtotime (date ('Ymurmshai donglue time (), array (' lt',strtotime ('date (' Ymurmlite donglagame time ().'+ 1 day')); / / time of the week $where ['time'] = array (array (' egt',strtotime (date ('Ymurmcopyright dazzle time ().'-'.date (' wicked moment time ()). Day'), array ('lt',strtotime (date (' Ymurmmurdjue time ().'+ 1 week-'.date (' wishful minute time ()). Day');); / / time of the month $where ['time'] = array (' egt',strtotime ('date (' Ymurmurmlaga time (), array ('lt',strtotime (date (' Ymurmlyne time ()).'+ 1 month') / / time of the year $where ['time'] = array (array (' egt',strtotime (date ('Yoshikwashi (), array (' lt',strtotime (date ('YLTHEROTY time ()).' + 1 year')
Above are the query conditions, which can be directly applied to the query statement.
$result = $db- > where ($where)-> select ()
Correct the query time of the above year.
$where ['time'] = array (array (' egt',strtotime (date ('Ymur01-01) recording time ()), array (' lt',strtotime (date ('Ymur01-01)). + 1 year')
Repair version
/ / yesterday's time $yesterday ['addtime'] = array (' egt',strtotime (date ('Ymurmmurdjinyashi ()).'-1 day')), array ('lt',strtotime (date ()) / / time of the day $day ['addtime'] = array (' egt',strtotime ('egt',strtotime (date (' Ymurmmurdjinyashi (), array ('lt',strtotime (date ()). + 1 day') / / time of the month $month ['addtime'] = array (array (' egt',strtotime (date ('Ykoshou pageTime (), array (' lt',strtotime (date ('Ylyphou month' time ()).' + 1 month')); / time of the week $week ['addtime'] = array (array (' egt',strtotime (date ('YlypheTime time ().'-.date ('wicked PowerTime ()). Day'), array ('lt',strtotime (date (' Ymurmmurdongju time ().'+ 1 week-'.date (' wicked magic time ()). Day')
After reading this article, I believe you have a certain understanding of "how to query this year's data in php". If you want to know more about it, please follow the industry information channel. Thank you for your reading!