参数:$birth_year:出生年份;$birth_month:出生月份;$birth_day:出生日
function getAgeByBirth($birth_year,$birth_month,$birth_day){
if(empty($birth_year) || empty($birth_month) || empty($birth_day)){
return 0;
}
$current_year = date('Y',time());
$current_month = date('m',time());
$current_day = date('d',time());
if($birth_year >= $current_year){
return 0;
}
$age = $current_year - $birth_year - 1;
if($current_month>$birth_month){
return $age+1;
}else if($current_month == $birth_month && $current_day>=$birth_day){
return $age+1;
}else{
return $age;
}
}
——现在的努力,只为小时候吹过的牛逼! ——
Original: https://www.cnblogs.com/zxf100/p/16400456.html
Author: 下页、再停留
Title: PHP 通过两个日期计算年龄
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/583360/
转载文章受原作者版权保护。转载请注明原作者出处!