note 66600 deleted from function.date by derick
| From: | derick@php.net | Date: | Sun, 11 Jun 2006 11:47:40 +0000 |
| Subject: | note 66600 deleted from function.date by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-114272@lists.php.net to get a copy of this message | ||
Note Submitter: gogge at outsid3rs dot com
----
Well I tried most (not all) of the other functions for getting a users age, but all of them had
flaws. So I had my hand at it and came up with the following. Hopefully, this should be of use to
some.
<?php
function getAge($bday, $bmonth, $byear){
if(date("n") > $bmonth){$
$age = date("Y") - $byear;
}elseif(date("n") == $bmonth){
if(date("j") >= $bday){
$age = date("Y") - $byear;
}elseif(date("j") < $bday){
$age = date("Y") - $byear - 1;
}
}elseif(date("n") < $bmonth){
$age = date("Y") - $byear - 1;
}
return $age;
}
?>
It's about the most correct check age function I've used so far.