Skip to content

Instantly share code, notes, and snippets.

View dev-w3's full-sized avatar
💻
Working from home

W3use dev-w3

💻
Working from home
View GitHub Profile
@dev-w3
dev-w3 / comparetime.php
Created September 27, 2022 09:18
change default timezone and check if current time is between two time
<?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)
{