PHP:在H:i中直接比较两次,并确定新时间是否在00:00之前

I currently have a start and end time in this format '00:00' e.g. H:i. I am currently trying to remove 4 hours from the time and then determine if the new time is the day before, e.g. before 00:00.

An example:

$oldStart =  '00:00';
$oldStart = date("H:i", strtotime($oldStart));
$oldEnd = '00:30';
$oldEnd = date("H:i", strtotime($oldEnd));
$newStart = date("H:i", strtotime('-4 hours', $oldStart));
$newEnd = date("H:i", strtotime('-4 hours', $oldEnd));
$dayStart = date("H:i", strtotime('00:00'));
if($newStart < $dayStart) {
    echo 'day before<br>';
} else {
    echo 'current day<br>';
}

I'm expecting this to echo 'day before' as the hours are now 4 hours behind, however it is echoing 'current day'. I can't see where I'm going wrong...

Just use this:

$old = "4:00";
$dt = new DateTime($old);
$dt->modify("-4 hours");
$new = $dt->format("Y-m-d");
if(date("Y-m-d", strtotime($old)) > $new){
    echo "Day before";
} else {
    echo "Same day";
}