I need to go to the next appointment which happens at the same time every day that's being modified, but when I modify it by the next interval day, it wipes the hours and minutes to 00:00
I've tried everything I can think of
foreach($recurring_appt as $ra)
{ //check for recurring appts next occurance
$check_rec_stop_date = new DateTime($ra->stop_recurring);
if($check_rec_stop_date >= $end_date){
$i=0;
if($ra->start_date <= $start_date->format('Y-m-d H:i:s')){
$t = new DateTime($ra->start_date);
$mod = 'next '.$days[$i][0];
$check_rec = clone $t->modify($mod);
echo $check_rec->format('m-d');
if($check_rec->format('m-d') == $start_date->format('m-d')){
array_push($rec_start_block,(new DateTime($ra->start_date))->modify($mod));
array_push($rec_end_block, (new DateTime($ra->end_date))->modify($mod));
}
}
// elseif()
}
$i++;
}
as I said - this modifies the date correctly to the next occurance of that appointment, but i resets the clock to 0:00 when I need it to keep that information, just modify the day (and month if applicable)
I think I will try the DateTimeImmutable when cleaning up my code to make it more efficient, but the only way around my original problem was to append the hours and minutes onto the modified date object after it has been modified:
$mod = 'next '.$days[$i][$j];
$check_rec = clone $t->modify($mod);
echo $check_rec->format('m-d')."
";
if($check_rec->format('m-d') == $start_date->format('m-d')){
array_push($rec_start_block, ((new DateTime($ra->start_date))->modify($mod)->setTime($hour, $mins)));
array_push($rec_end_block, ((new DateTime($ra->end_date))->modify($mod)->setTime($chour, $cmins)));
}