| > Projects > PHP > Age Calculation |
PHP > Age Calculation
A simple function which subtracts the the birthday from the current date.
<?php
/**
* CALCAGE
* Calculates age
*
* @param String $bday A birthday in any English textual datetime
* @return String The age in years
*/
function calcAge($bday)
{
return floor(((time() - strtotime($bday)) / 86400) / 365);
}
//echo 'I am '.calcAge('June 21, 1988').' years old';
?>
|