Blogger Information
Blog 8
fans 0
comment 0
visits 12239
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
根据身*份*证信息获取年龄
杨家二少
Original
368 people have browsed it
function identityToAge($id){
   if(empty($id)) return '';
   $date=strtotime(substr($id,6,8));
   //获得出生年月日的时间戳
   $today=strtotime('today');
   //获得今日的时间戳
   $diff=floor(($today-$date)/86400/365);
   //得到两个日期相差的大体年数
   //strtotime加上这个年数后得到那日的时间戳后与今日的时间戳相比
   $age=strtotime(substr($id,6,8).' +'.$diff.'years')>$today?($diff+1):$diff;
   return $age;
}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post