Last active
August 29, 2015 14:21
-
-
Save wesamly/622d481b05f0586c54e4 to your computer and use it in GitHub Desktop.
Execute code within given time 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 | |
$y = date('Y'); | |
$m = date('m'); | |
$d = date('d'); | |
$restrictStart = mktime(0, 30, 0, $m, $d, $y); | |
$restrictEnd = mktime(1, 30, 0, $m, $d, $y); | |
$time = time(); | |
if ($time < $restrictStart || $time > $restrictEnd) { | |
die('not yet!'); | |
} | |
//Code to execute here | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can set up a cron job that runs every minute, for example, and code will make sure to execute only when time between 00:30 and 01:30.