note 42348 added to function.date
| From: | dylanATEcmgDAWTla at rn2 dot php dot net | Date: | Wed, 12 May 2004 22:56:12 +0000 |
| Subject: | note 42348 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69539@lists.php.net to get a copy of this message | ||
I fixed the above 'find out how old somebody is' function.
function Convert_DOB_to_Age($DOB) // $DOB is in YYYY-MM-DD format
{
//explode $DOB to an array for easy processing.
$DOBArray = explode("-", $DOB);
// Get today's year, month and day'
$TodayDay = date('d');
$TodayMonth = date('m');
$TodayYear = date('Y');
// The logic
if (($TodayMonth > $DOBArray[1]) || (($TodayMonth == $DOBArray[1]) && ($TodayDay <=
$DOBArray[2])))
$Age = $TodayYear - $DOBArray[0];
else
$Age = $TodayYear - $DOBArray[0] - 1;
// return the age
return $Age;
}
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42348
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42348&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42348&report=yes
Search -- http://master.php.net/manage/user-notes.php