php hours between two dates code example
Example 1: get hours difference between two dates in php
$hourdiff = round((strtotime($time1) - strtotime($time2))/3600, 1);
Example 2: php hour between
$currentTime = (new DateTime('01:00'))->modify('+1 day');
$startTime = new DateTime('22:00');
$endTime = (new DateTime('07:00'))->modify('+1 day');
if ($currentTime >= $startTime && $currentTime <= $endTime) {
// Do something
}