Created
November 16, 2016 06:08
-
-
Save Gesparo/c37ba26d1fc17d46b037274d6557665e to your computer and use it in GitHub Desktop.
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
/** | |
* Calculate time remaining to work hours | |
*/ | |
$curTimestamp = time(); // сегодняшнее число в unix формате | |
$curHour = (new DateTime('now', new DateTimeZone('Asia/Yekaterinburg')))->format('G'); // текущий час | |
$receiveTime = 0; // время получиеня | |
// если время позднее | |
if( $curHour >= 19 && $curHour <= 24 ) | |
{ | |
$newDate = new DateTime('now'); | |
$newDate->add(new DateInterval('P1D')); | |
$newDate->setTime(9, 0); | |
$receiveTime = $newDate->getTimestamp(); | |
} | |
else if( $curHour >= 0 && $curHour < 9 ) | |
{ | |
$newDate = new DateTime('now'); | |
$newDate->setTime(9, 0); | |
$receiveTime = $newDate->getTimestamp(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment