note 66600 added to function.date
| From: | gogge at outsid3rs dot com | Date: | Thu, 25 May 2006 10:44:20 +0000 |
| Subject: | note 66600 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112121@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 129.16.214.50
Probable Submitter: 213.112.160.81
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/note/edit/66600
Del: integrated -- http://master.php.net/note/delete/66600/integrated
Del: useless -- http://master.php.net/note/delete/66600/useless
Del: bad code -- http://master.php.net/note/delete/66600/bad+code
Del: spam -- http://master.php.net/note/delete/66600/spam
Del: non-english -- http://master.php.net/note/delete/66600/non-english
Del: in docs -- http://master.php.net/note/delete/66600/in+docs
Del: other reasons-- http://master.php.net/note/delete/66600
Reject -- http://master.php.net/note/reject/66600
Search -- http://master.php.net/manage/user-notes.php