Skip to content

Instantly share code, notes, and snippets.

@themainframe
Created December 30, 2012 02:10
Show Gist options
  • Save themainframe/4410571 to your computer and use it in GitHub Desktop.
Save themainframe/4410571 to your computer and use it in GitHub Desktop.
next_time.php
<?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