note 33931 deleted from ref.datetime by cece
| From: | cece@php.net | Date: | Wed, 20 Aug 2003 13:47:35 +0000 |
| Subject: | note 33931 deleted from ref.datetime by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54755@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Another age calculator.
The argument has to be in the standard mysql format (y-m-d)...
function age($date) {
if (!$date) return false;
$year=0+substr($date,0,4);
$month=0+substr($date,5,2);
$day=0+substr($date,8,2);
$t=0;
$d=date("d");
$m=date("m");
$y=date("Y");
$age=$y-$year;
if ($m<$month) $t=-1;
else if ($m==$month) if ($d<$day) $t=-1;
return ($age+$t);
}