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;
}
$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;
}
上一篇: 这种情况如何解决呢