note 12682 deleted from function.strftime by sniper
| From: | sniper@php.net | Date: | Wed, 15 Jan 2003 09:37:20 +0000 |
| Subject: | note 12682 deleted from function.strftime by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-42162@lists.php.net to get a copy of this message | ||
I've seen some horribly long scripts to find the diff between 2 dates, but here's what I
did to find how old I am! Works only for dates after the Unix epoch, (ie) 1.1.1970
<p>
<?php
$diff = time() - mktime(8,30,0,1,12,1978,0);
/*Jan 12th 1978, 8:30 AM*/
$week = strftime("%W",$diff);
$year = strftime("%Y",$diff) - 1970;
$day = strftime("%w",$diff);
echo "($year years, $week weeks and $day days)";
?></p>