糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > php 周岁 PHP求周岁

php 周岁 PHP求周岁

时间:2022-01-03 10:59:36

相关推荐

php 周岁 PHP求周岁

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‘) < $month || (date(‘m‘) == $month && date(‘d‘) < $day)) $age--;

return $age;

}

/**

* 计算年龄

* @param $args

* @return number:返回当前年龄

*/

private function getAge($birthyear,$birthday){

$year = date("Y");

$date = date(‘md‘);

$add_age = $birthday < $date ? 0 : -1;

$age = $year - $birthyear + $add_age;

if($age < 18){

$age = 18;

}

return $age;

}

原文:http://ouyangjun./10284323/1718971

如果觉得《php 周岁 PHP求周岁》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。