note 31478 added to function.strtotime
| From: | "patrick�bierans�de" at rack1 dot php dot net | Date: | Wed, 23 Apr 2003 13:41:17 +0000 |
| Subject: | note 31478 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46982@lists.php.net to get a copy of this message | ||
<?php
$start="2003-04-23 15:12:59";
$end ="2003-04-25 14:12:29";
$interval=strtotime($end)-strtotime($start);
echo $interval."\n";
print_r(interval_as_array($interval));
function interval_as_array($sec)
{
$min=0;
$hour=0;
$day=0;
$year=0;
if ($sec>60)
{
$min=floor($sec/60);
$sec-=$min*60;
}
if ($min>60)
{
$hour=floor($min/60);
$min-=$hour*60;
}
if ($hour>24)
{
$day=floor($hour/24);
$hour-=$day*24;
}
if ($day>365)
{
$year=floor($day/365);
$day-=$year*365;
}
return
array('y'=>$year,'d'=>$day,'h'=>$hour,'m'=>$min,'s'=>$sec);
} // interval_as_array()
?>
--
http://www.php.net/manual/en/function.strtotime.php
http://master.php.net/manage/user-notes.php?action=edit+31478
http://master.php.net/manage/user-notes.php?action=delete+31478
http://master.php.net/manage/user-notes.php?action=reject+31478