Hello i want to check if the current time is between two time range and calculate the difference between them, so far i have this but its not working
$current_time = "11:14 pm"; $start_time = "11:00 pm"; $end_time = "07:55 am"; $date1 = DateTime::createFromFormat('H:i a', $current_time); $date2 = DateTime::createFromFormat('H:i a', $start_time); $date3 = DateTime::createFromFormat('H:i a', $end_time); if ($date1 > $date2 && $date1 < $date3) { echo 'in range'; } else { echo 'not in range'; } But it says "not in range"!
$date1and 2 and 3 are not integers$date1will be more than$date2but it will never be less than$date3at the same time. Not with the times you've supplied us. 11:14 pm is NOT LESS than 07:55 am, it's more.