I'm getting the opening and closing time of a store in HHMM format (0000 to 2359):
$openingtime = intval($open->time);
$closingtime = intval($close->time);
Then I get the current time in the same format:
$nowtime = intval(date("G") . date("i"));
I want to know whether the current time is between 15 minutes before the opening time, and 45 minutes before the closing time.
I have this, but it is inaccurate:
if(($nowtime >= ($openingtime - 15)) && ($nowtime <= ($closingtime - 45))){
// current time is between 15 minutes before opening and 45 minutes before closing
}
If the time is 2300, then 2300 - 15 = 2285, which isn't a valid time.
How can I resolve this?
Also, I assume I need to do something at the overlap of the day (0000), but I'm not sure what I need to do there.