记通过身份证号计算是否成年

$card_id="211321200303160000"; // 有用的数据只有下标(6,10)
/*判断年龄*/

$date=strtotime(substr($card_id,6,8));
$today=strtotime('today');
$diff=floor(($today-$date)/86400/365);
$age=strtotime(substr($card_id,6,8).' +'.$diff.'years')>$today?($diff-1):$diff;


echo $age;
原文地址:https://www.cnblogs.com/liiu/p/14543344.html