Due to project requirements, data from the specified date period needs to be processed on a daily basis.
For example, the data for each day of the date period from 2016-06-01 to 2016-06-05 needs to be processed. First you need to get the date of each day in this date period, and then loop through the processing.
$date = array('2016-06-01','2016-06-02','2016-06-03','2016-06-04','2016-06-05');foreach($dateas$d){ // 执行处理}?>
If the date period spans large (2015-09-01 to 2016-06-30) and there are cross-year, cross-month (leap months) situations, the manual creation date array is too time-consuming and unreasonable.
As a result, you can get the date of each day in the specified date period by writing the following code:
/** * Gets the date of each day in the specified date period * @param Date $startdate start date * @param Date $enddate End Date * @ret Urn Array *
/ functiongetdatefromrange($startdate, $enddate){$stimestamp= Strtotime ($startdate);$etimestamp= Strtotime ($enddate);//Calculate how many days in a date period$days= ($etimestamp-$stimestamp)/86400+1;//Save daily date$date=Array(); for($i=0;$i<$days;$i++){$date[] = Date (' y-m-d ',$stimestamp+(86400*$i)); }return$date;}//Demo$date= Getdatefromrange (' 2016-02-25 ',' 2016-03-05 ');p Rint_r ($date);?>
Output:
Array( [02016-02-25 [12016-02-26 [22016-02-27 [32016-02-28 [42016-02-29 [52016-03-01 [62016-03-02 [72016-03-03 [82016-03-04 [92016-03-05)
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the PHP get start date and end date of all dates, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.