Dates according to the number of days

by Miqeas Pedro Mendes   Last Updated September 11, 2019 19:26 PM - source

I need your help, please. I want to classify the dates according to the number of days to have for example: every 1 of the dates, every two, and so on.

$date1= strtotime('2019-09-01'); $date2= strtotime('2020-06-30');

$nbjour=($date2-$date1)/60/60/24;

for($i=0; $i <= $nbjour; $i++) {

setlocale(LC_TIME, "fr_FR");
$day = strftime('%A',$date1);

     if ($day === 'Dimanche' || $day === 'Samedi') {
              $date = strftime('%A %d %B %G',$date1). ' weekend';
        }
        else{
              $date = strftime('%A %d %B %G',$date1);
        }
 echo $date;
 $date1+=60*60*24; 
 echo'<br />' ;

}

I want to get this result

[01-09-2019 01-10-2019 01-12-2019 ... 02-09-2019 02-10-2019 ... 03-09-2019]

Tags : php sorting date


Related Questions


javascript: changing date format but not to string

Updated February 16, 2019 04:26 AM


How to sort list of dates in php?

Updated July 07, 2019 02:26 AM