function diff($startTime, $endTime)
{
$startDate = new \DateTime($startTime);
$endDate = new \DateTime($endTime);
if ($startTime == $endTime) {
return 24;
}
if ($startDate >= $endDate) {
$startDate = $startDate->modify('-1 day');
}
$diff = $startDate->diff($endDate);
return $diff->h;
}
print(diff('05:00:00', '04:00:00'));