note 39457 added to function.date
| From: | monitio at spamaway dot hotmail dot com | Date: | Thu, 29 Jan 2004 11:17:49 +0000 |
| Subject: | note 39457 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64363@lists.php.net to get a copy of this message | ||
As a reply to eric_zander at yahoo dot com's DoB script, I should add that it can be done much
easier with this little snippet:
<?php
# Convert a date of birth to current age.
#
# Example (for 11 april, 1985): dob2age(11, 04, 1985);
# Should return: 18 (on the day of this post)
#
function dobToAge($d, $m, $y)
{
if (date("m") >= $m && date("d") >= $d)
$age = date("Y")-$y;
else
$age = date("Y")-$y-1;
return $age;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39457
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39457&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39457&report=yes
Search -- http://master.php.net/manage/user-notes.php