Created
January 15, 2020 16:29
-
-
Save royce002/798affd8190c0e90c27aab1cc01061c7 to your computer and use it in GitHub Desktop.
Sets the timezone, and checks current time to see if it lies between a start and ending range.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set('america/chicago'); | |
$currentDayTime = new DateTime(); // Get Today's Date/Time | |
echo $currentDayTime->format('m-d-Y H:i') . "<br>"; | |
$startDateTime = new DateTime('2020-01-15'); | |
$startDateTime->setTime(8, 00); | |
echo $startDateTime->format('m-d-Y H:i') . "<br>"; | |
$endDateTime = new DateTime('2020-01-15'); | |
$endDateTime->setTime(10, 26); | |
echo $endDateTime->format('m-d-Y H:i') . "<br>"; | |
if (($currentDayTime >= $startDateTime) && ($currentDayTime <= $endDateTime)){ | |
echo "<h1>LETS DO STUFF</h1>"; | |
}else{ | |
echo "Date not in range"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment