Created
December 30, 2012 02:10
-
-
Save themainframe/4410571 to your computer and use it in GitHub Desktop.
next_time.php
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 | |
/** | |
* Get the UNIX timestamp of the next instance of a time. | |
* | |
* @param int $hours The hours. | |
* @param int $minutes Optionally, the minutes. Default 0. | |
* @return int | |
*/ | |
function next_time($hours, $minutes = 0) | |
{ | |
$c = time(); | |
$c_hour = $c_minute = 0; | |
while($c_hour != $hours || | |
$c_minute != $minutes) | |
{ | |
$c += 60; | |
$c_hour = date('G', $c); | |
$c_minute = date('i', $c); | |
} | |
return $c; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment