note 42345 added to function.floor
| From: | illyena at musefish dot net | Date: | Wed, 12 May 2004 19:53:40 +0000 |
| Subject: | note 42345 added to function.floor | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69536@lists.php.net to get a copy of this message | ||
For calculating the number of days, hours, minutes and seconds to an event.
<?
$then = date(mktime(8,0,0,6,25,2004)); //remember that mktime is hour,min,sec,month,day,year
$now = date("U"); // "U" is the number of seconds since the epoch, equivilant to
using "YmdHis"
$time = $then - $now; //gets the number of seconds between now and the event
$days = floor($time/86400); //rounds down to the whole number, in this case # of days
echo $days." Days";
$time = $time - ($days*86400); //leaves you with the amount of time ramaining after subtracting the
days
$hours = floor($time/3600); //rounds down to the whole number, in this case # of hours
echo $hours." Hours";
$time = $time - ($hours*3600); //leaves you with the amount of time ramaining after subtracting the
hours
$min = floor($time/60); //rounds down to the whole number, in this case # of minutes
echo $min." Minutes";
$sec = $time - ($min*60); //leaves you with the amount of time ramaining after subtracting the
minutes which is equivilant to the remainins seconds
echo $sec." Seconds";
?>
----
Manual Page -- http://www.php.net/manual/en/function.floor.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42345
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42345&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42345&report=yes
Search -- http://master.php.net/manage/user-notes.php