note 38708 added to function.getdate
| From: | seanatboyercentraldotnet at rn2 dot php dot net | Date: | Sun, 04 Jan 2004 04:16:04 +0000 |
| Subject: | note 38708 added to function.getdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62884@lists.php.net to get a copy of this message | ||
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;
}
----
Manual Page -- http://www.php.net/manual/en/function.getdate.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38708
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38708&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38708&report=yes
Search -- http://master.php.net/manage/user-notes.php