首页 > 代码库 > PHP计算年龄

PHP计算年龄

function age($YTD){
$YTD = strtotime($YTD);
$year = date(‘Y‘, $YTD);
if(($month = (date(‘m‘) - date(‘m‘, $YTD))) < 0){
$year++;
}else if ($month == 0 && date(‘d‘) - date(‘d‘, $YTD) < 0){
$year++;
}
return date(‘Y‘) - $year;
}

PHP计算年龄