The examples in this article describe how PHP gets all the dates between the start and end dates. Share to everyone for your reference, specific as follows:
/**
* Gets the date of each day in the specified date
* @param date $startdate start date
* @param date $enddate End date *
@return Array
* /
function Getdatefromrange ($startdate, $enddate) {
$stimestamp = Strtotime ($startdate);
$etimestamp = Strtotime ($enddate);
Calculate the number of days in the date
$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;
}
$startdate = ' 2016-08-29 ';
$enddate = ' 2016-09-29 ';
Demo
$date = Getdatefromrange ($startdate, $enddate);
Print_r ($date);
The results of the operation are as follows:
Array
(
[0] => 2016-08-29
[1] => 2016-08-30
[2] => 2016-08-31
[3] => 2016-09-01
[4 ] => 2016-09-02
[5] => 2016-09-03
[6] => 2016-09-04
[7] => 2016-09-05
[8] => 2016-09-06< C11/>[9] => 2016-09-07
[a] => 2016-09-08
[one] => 2016-09-09
[[] => 2016-09-10
[13] =& Gt 2016-09-11
[[] => 2016-09-12
[a] => 2016-09-13
[a] => 2016-09-14
[] => 2016-09-15
[=>] 2016-09-16
[A] => 2016-09-17
[a] => 2016-09-18
[[] => 2016-09-19
[] =>
2016-09-20 2016-09-21
[A] => 2016-09-22
[a] => 2016-09-23
[a] => 2016-09-24
[a] => 2016-09-25
[=>] 2016-09-26
[A] => 2016-09-27
[] => 2016-09-28 [to]
=> 2016-09-29
)
For more information on PHP related content readers can view the site topics: "The PHP date and time usage summary", "PHP array Operation technique Encyclopedia", "PHP basic Grammar Introductory Course", "PHP operation and operator Usage Summary", "PHP object-oriented Program Design Introduction Course", " PHP Network Programming skills Summary, "PHP string (String) Usage Summary", "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design.