I have several shops in my system. Now i online want to show shops that are open or will open if the nowtime is before the closing time. the time strings I use are 24 hour format like "01:00" and "23:22" I came up with a code like this:
public function willOpen($open, $closed, $nowTime) {
$open = str_replace(":", "", $open);
$closed = str_replace(":", "", $closed);
$nowTime = str_replace(":", "", $nowTime);
if ($open >= $nowTime) {
if ($closed <= $nowTime) {
return false;
} else {
return true;
}
}
return false;
}
But this does not seem right because if the close time is for ex. 01:00 and the current time is 9:00 and the shop will open for ex 11:00 then this code will return false because the close time is smaler then the now time.....
what is the best approach do to this ?