×

php 通过身份证号算年龄

chen chen 发表于2021-07-27 22:40:59 浏览525 评论0

抢沙发发表评论

function getAgeByID($id){
if(empty($id)) return '';
$date=strtotime(substr($id,6,8));
$today=strtotime('today');
$diff=floor(($today-$date)/86400/365);
$age=strtotime(substr($id,6,8).'+'.$diff.'years')>$today?($diff+1):$diff;
return $age;
}


群贤毕至

访客