1

I have a given time range booking var from the user, i.e. Monday, 10:00 ($time_pickup_user) to 14:00 ($time_return_user), all in European 24h times.

Now I want to check if a company is opened in the given range.

Example company hours:

Monday: 08:00 ($monday_open) to 18:30 ($monday_close)

I am checking this with the following code:

if ($monday_open > $time_pickup_user OR $monday_close < $time_pickup_user) {
 $company_closed = "true";
}

if ($monday_close < $time_return_user OR $monday_open > $time_return_user) {
 $company_closed = "true";
}

It works quite well. The problem: If I set the company hours to Monday: 05:00 ($monday_open) and 00:30 ($monday_close) (= closing time AFTER 00:00), it always trigger $company_closed to true, no matter which time range the user enters.

Any hints how to solve this comparison problem? Thanks a bunch!

0 Answers0