note 25786 added to function.date
| From: | alex at rack1 dot php dot net | Date: | Sun, 06 Oct 2002 05:08:49 +0000 |
| Subject: | note 25786 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37712@lists.php.net to get a copy of this message | ||
Yet another simple way to calculate the age, by transforming the actual date in a floating point
number:
provided $fdate in the format: YYYY-MM-DD
$f = strtok($fdate,'-') . '.' . strtok('-') . strtok('-');
$l = date('Y.md');
$age = floor($l - $f);
ex: today - birthday
2002.1006 - 2000.1005 = 2.0001 => 2 years old
2002.1004 - 2000.1005 = 1.9999 => 1 year old
2002.1005 - 2000.1005 = 2.0000 => 2 years old
--
http://www.php.net/manual/en/function.date.php
http://master.php.net/manage/user-notes.php?action=edit+25786
http://master.php.net/manage/user-notes.php?action=delete+25786
http://master.php.net/manage/user-notes.php?action=reject+25786