Getting the previous and next 7 days from a specific date
$date = new DateTime();
$today = $date->format('m d, Y');
How can I get the previous 7 and next 7 days from $today? and loop them in an array.
Getting the previous and next 7 days from a specific date
$date = new DateTime();
$today = $date->format('m d, Y');
How can I get the previous 7 and next 7 days from $today? and loop them in an array.
Something different to the other answers but what about
$start = new DateTime();
$end = new DateTime();
$start = $start->modify( '-7 days' );
$end = $end->modify( '+8 days' ); // Date Period doesn't include the end date
$interval = new DateInterval('P1D');
$daterange = new DatePeriod($start, $interval ,$end);
foreach($daterange as $date){
echo $date->format("'m d, Y'") . "<br>";
}