The database stores data on the operating time of the company in the format: 09: 00.18: 30; 12: 00.02: 00, etc. It is necessary to compare the current time with two intervals (the beginning / end of the working day) and if the current time is between working hours, return true, otherwise false.
I convert and try to compare this:
$start = strtotime($start_work); $end = strtotime($end_work); if ($current_time >= $start && $current_time <= $end) { ... } else { ... } How does it work
The company is open from 08:30 to 18:00, and the current time is 12:00. In this case, everything is fine. Everything is displayed correctly
How does not work
the company is open from 08:30 to 02:00, and the current time is 12:00.
In general, the problem is if any time after midnight. because it is essentially less (from 0) I was looking for options, I found a lot of questions about this, but I could not find an answer.
How can this issue be resolved? Thank.