note 9643 deleted from ref.datetime by victor
| From: | victor@php.net | Date: | Mon, 09 Dec 2002 18:49:00 +0000 |
| Subject: | note 9643 deleted from ref.datetime by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40604@lists.php.net to get a copy of this message | ||
need the age of a person or how many years passed since a certain date?
this should work, also works when the person is born on Feb, 29th
function get_age($birthday) {
if (!ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $birthday, $regs)) { return false;} //
Geb-Datum nicht korrekt übergeben
$age = date("Y") - $regs[1];
if ($regs[2] > date("m")) {$age--;}
elseif ($regs[2] == date("m")) {
if ($regs[3] > date("d")) {$age--;}
}
return $age;
} // Ende function get_age