Parašė Peacemaker· 2009 Gru. 15 12:12:36
#6
Radau vieną variantą, gal principas tiks:
<?php
//calculate years of age (input string: YYYY-MM-DD)
function birthday ($birthday){
list($year,$month,$day) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
if ($day_diff < 0 || $month_diff < 0)
$year_diff--;
return $year_diff;
}
?>
Kiats variantas:
<?php
function agebydate($iMonth, $iDay, $iYear) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365 ); 1
return $iYears;
}
?>
Redagavo Peacemaker· 2009 Gru. 15 12:12:56