If you want to reverse a date interval use array_reverse and iterator_to_array. I've found using invert to be unreliable.
<?php
$start_date = date_create("2021-01-01");
$end_date = date_create("2021-01-05"); $interval = DateInterval::createFromDateString('1 day');
$daterange = new DatePeriod($start_date, $interval ,$end_date);
function show_dates ($dr) {
foreach($dr as $date1){
echo $date1->format('Y-m-d').'<br>';
}
}
show_dates ($daterange);
echo '<br>';
$daterange = array_reverse(iterator_to_array($daterange));
show_dates ($daterange);
?>
Gives
2021-01-01
2021-01-02
2021-01-03
2021-01-04
2021-01-04
2021-01-03
2021-01-02
2021-01-01