note 33931 added to ref.datetime
| From: | php-general at lists dot php dot net | Date: | Fri, 11 Jul 2003 11:30:46 +0000 |
| Subject: | note 33931 added to ref.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51902@lists.php.net to get a copy of this message | ||
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);
}
----
Manual Page -- http://www.php.net/manual/en/ref.datetime.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33931
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33931&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33931&report=yes