Calculators
|
|
|
|
<?php function getAgeByDate ($iMonth, $iDay, $iYear, $nMonth=0, $nDay=0, $nYear=0) {
// simple mm/dd/yy(yy) to age conversion.
// Copyright (C)2001 Servability Ltd. Beerware!!
If (!$nMonth) $nMonth = date("m");
If (!$nDay) $nDay = date("d");
If (!$nYear) $nYear = date("Y");
If ($iYear < 100) {
$iYear = 1900 + $iYear;
}
$baseyear = $nYear - $iYear - 1;
If ($iMonth < $nMonth OR ($iMonth == $nMonth AND $iDay <= $nDay)) {
// had birthday
$baseyear++;
}
return $baseyear;
} ?>
|
|
|
Usage Example
|
print getAgeByDate(5,26,1979) . " now <br>";
print getAgeByDate(5,26,79,2,5,2020) . " on 2nd May 2020<br>";
|
|
|
Rate This Script
|
|
|
|