欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP求周岁

程序员文章站 2022-05-16 23:25:52
...
function getAge($birthday) {
$age = 0;
$year = $month = $day = 0;
if (is_array($birthday)) {
extract($birthday);
} else {
if (strpos($birthday, '-') !== false) {
list($year, $month, $day) = explode('-', $birthday);
$day = substr($day, 0, 2);
}
}
$age = date('Y') - $year;
if (date('m') return $age;
}


/**
* 计算年龄
* @param $args
* @return number:返回当前年龄
*/
private function getAge($birthyear,$birthday){
$year = date("Y");
$date = date('md');
$add_age = $birthday $age = $year - $birthyear + $add_age;
if($age $age = 18;
}
return $age;
}

相关标签: PHP求周岁