Created
September 27, 2022 09:18
-
-
Save dev-w3/e0497a9b52bd02e6c0a0c7889973e0e8 to your computer and use it in GitHub Desktop.
change default timezone and check if current time is between two time
This file contains hidden or 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 | |
$estTime = (new DateTime('America/New_York'))->format('h:i a'); | |
$current_time = $estTime; | |
$sunrise = "12:00 am"; | |
$sunset = "03:00 am"; | |
$date1 = DateTime::createFromFormat('h:i a', $current_time); | |
$date2 = DateTime::createFromFormat('h:i a', $sunrise); | |
$date3 = DateTime::createFromFormat('h:i a', $sunset); | |
if ($date1 > $date2 && $date1 < $date3) | |
{ | |
echo '<h3>System is down for maintenance daily from 12am EST to 3am EST</h3>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment