note 11885 added to function.mktime.php
| From: | mikepc at gamebaz dot com | Date: | Mon, 12 Mar 2001 06:01:30 +0000 |
| Subject: | note 11885 added to function.mktime.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-12286@lists.php.net to get a copy of this message | ||
Here is a simple algorithm to "count down" exact time to a specific timestamp.
$target is a php timestamp sometime in the future.
$diff is the difference between then and now.
... so we begin
$diff = $target - time();
$days = ($diff - ($diff % 86400)) / 86400;
$diff = $diff - ($days * 86400);
$hours = ($diff - ($diff % 3600)) / 3600;
$diff = $diff - ($hours * 3600);
$minutes = ($diff - ($diff % 60)) / 60;
$diff = $diff - ($minutes * 60);
$seconds = ($diff - ($diff % 1)) / 1; // the /1 thing is a little much but what the hell :P
http://www.php.net/manual/en/function.mktime.php