note 43184 deleted from function.mktime by tomsommer

From: Date: Sat, 12 Jun 2004 13:23:16 +0000
Subject: note 43184 deleted from function.mktime by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-70971@lists.php.net to get a copy of this message
Note Submitter: post@matthias-wuttke.de ---- Yet another birthday calculator. I think these two functions also work before 1970. Date format for the birthdate is "YYYY-MM-DD". <?php // returns the age of a person function age($birthdate) { $date = explode("-", $birthdate); $now = getdate(); $age = $now['year'] - $date[0]; if (time() < mktime(0, 0, 0, $date[1], $date[2], $now['year'])) $age--; return $age; } // returns the next birthday function next_birthday($birthdate) { $date = explode("-", $birthdate); $now = getdate(); $year = $now['year'] + 1; if (time() < mktime(0, 0, 0, $date[1], $date[2], $now['year'])) $year--; return $year . "-" . $date[1] . "-" . $date[2]; } ?>

« previous php.notes (#70971) next »