200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > php计算根据出生日期计算年龄

php计算根据出生日期计算年龄

时间:2023-06-04 22:35:14

相关推荐

php计算根据出生日期计算年龄

//根据出生日期计算年龄,如果传入的出生日期为.01格式,则把.正则替换为-function countAge($birthday){$birthday=preg_replace("/\./i", '-', $birthday);$age = strtotime($birthday);if($age === false){return false;}list($y1,$m1,$d1) = explode("-",date("Y-m-d",$age));$now = strtotime("now");list($y2,$m2,$d2) = explode("-",date("Y-m-d",$now));$age = $y2 - $y1;if((int)($m2.$d2) < (int)($m1.$d1))$age -= 1;return $age;}

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