Here is the function I created to get your needs:
function datesOfNextWeek() { $dates = array(); $date = time(); // get current date. while (date('w', $date += 86400) != 1); // find the next Monday. for ($i = 0; $i < 7; $i++) { // get the 7 dates from it. $dates[] = date('Ym-d', $date + $i * 86400); } return $dates; }
Please note that the value of 86400 is the result of 24 * 60 * 60 , which means 86400 seconds or 1 day (24 hours * 60 minutes * 60 seconds).
To use it in your code, use the following:
list( $date_monday, $date_tuesday, $date_wednesday, $date_thursday, $date_friday, $date_saturday, $date_sunday ) = datesOfNextWeek();
There, I hope this helps!
source share