note 42348 deleted from function.date by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 17 Jul 2004 13:19:44 +0000 |
| Subject: | note 42348 deleted from function.date by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73442@lists.php.net to get a copy of this message | ||
Note Submitter: dylan ATE cmg DAWT la
----
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;
}