note 25786 deleted from function.date by victor
| From: | victor@php.net | Date: | Sun, 08 Dec 2002 20:04:35 +0000 |
| Subject: | note 25786 deleted from function.date by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40538@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