note 30581 added to function.strtotime
| From: | Anneoldon at rack1 dot php dot net | Date: | Sat, 22 Mar 2003 23:28:02 +0000 |
| Subject: | note 30581 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45658@lists.php.net to get a copy of this message | ||
Here is a function that calculate the difference between one date and now.
$dif[2] is only used when the month is the same. I give the difference between days.
function diffd($tims, &$dif)
{
$no = getdate();
$tims = strtotime($tims);
$da = getdate($tims);
if ($no["mon"]-$da["mon"]<0)
{
$moin=1;
}
elseif
(($no["mon"]-$da["mon"]==0)&&($no["mday"]-$da["mday"]<0))
{
$moin=1;
}
else
$moin = 0;
$dif[0]=$no["year"]-($da["year"]+$moin);
if ($moin==1)
{
if ($dif[0]==0)
$dif[1]=$no["mon"]-$da["mon"];
else
$dif[1]=12-($no["mon"]-$da["mon"]);
}
else
{
$dif[1]=$no["mon"]-$da["mon"];
}
$dif[2]=$no["mday"]-$da["mday"];
}
--
http://www.php.net/manual/en/function.strtotime.php
http://master.php.net/manage/user-notes.php?action=edit+30581
http://master.php.net/manage/user-notes.php?action=delete+30581
http://master.php.net/manage/user-notes.php?action=reject+30581