I am trying to write some code that will basically tell me if it's between 9pm and 9am central time.
This will be part of a script that will page our techs only if it's after hours.
The code I have is below but for some reason it's not working, when I run it now which is currently 11:58 pm central, it tells me it's normal hours which is incorrect.
If I just try to detect if it's after 9pm that works, once I add the "&&" and the "< 09" it breaks.
Any idea why? 😕
$CentralDateTime = strtotime($date . '-1 hour');
$MyTime = date("H", $CentralDateTime);
//To simulate the hour for testing
//$MyTime = 05;
print "The hour now is: " . $MyTime;
if ($MyTime > 20 && $MyTime < 9) {
print "<br>It's after hours";
}else{
print "<br>It's normal hours";
}