Get age by date
This function example returns the age of a person by theyre date of birth
<?php
/**************************************************
*
* int getAgeByDate(int $mm, int $dd, int $yyyy)
*
**************************************************
*
* Returns age of person by the person's birth date
*
**************************************************
*
* Parameters:
* $mm - Month of birth
* $dd - Day of birth
* $yyyy - Year of birth
*
**************************************************
*
* Return value
* Age of person
*
**************************************************
*
* Author: Matthew R. Villa <matt@1-percent.com>
* Last modified: 10.01.2000
*
* Copyright (c) 2000 1-Percent.com
*
*/
function getAgeByDate($iMonth, $iDay, $iYear) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
}
?>
Usage
echo getAgeByDate(04, 17, 1980);
The result will display "22"