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;
}
posted @ 2015-01-24 11:59  唐扬平  阅读(229)  评论(0编辑  收藏  举报