note 38708 deleted from function.getdate by derick
| From: | derick@php.net | Date: | Sun, 29 Feb 2004 11:10:36 +0000 |
| Subject: | note 38708 deleted from function.getdate by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65988@lists.php.net to get a copy of this message | ||
Note Submitter: sean at boyercentral dot net
----
I looked forever to find a function that would simply return someone's age from their birthday.
After a lot of tinkering, I made my own! Hope this comes in handy for someone!
<?php
function DOB2age($year,$month,$day){
$now = getdate();
$age = $now[year] - $year;
// 0's are hours, mintes, seconds - Add the vars yourself if you need to use them.
// Remove the next line if your $year is 4 digits (ie 1989 rather than 89)
$year="19$year";
if (time() < mktime(0, 0, 0, $month, $day, $c[year]))
{
$age--;
}
return $age;
}