note 45615 deleted from function.time by aidan
| From: | aidan@php.net | Date: | Sat, 08 Oct 2005 01:05:14 +0000 |
| Subject: | note 45615 deleted from function.time by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96625@lists.php.net to get a copy of this message | ||
Note Submitter: joshuaditty at cardinal-points dot com
----
Sometimes you'll need to display the amount of time left before a certain event occurs (like
the end of an auction) in a format like this:
2d 4h 59m 23s
This can be done using three lines of code:
<?php
$events_time = Timestamp of the date;
$time_left = $events_time - time();
$time_left = (floor($time_left/86400))."d
".floor(($time_left-(floor($time_left/86400)*86400))/3600)."h
".floor(($time_left-(floor($time_left/3600)*3600))/60)."m
".floor($time_left-(floor($time_left/60))*60)."s";
?>