最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php根据身份证号码计算年龄
时间:2022-06-24 21:29:33 编辑:袖梨 来源:一聚教程网
代码如下 | 复制代码 |
function getAgeByID($id){ //过了这年的生日才算多了1周岁 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; } ?> |
相关文章
- 《星球工匠》电路板获得方法 04-19
- 《长安小时光》下载方法方法 04-19
- 《下一站江湖2》情比金坚作用介绍 04-19
- 《星露谷物语》获得地板方法 04-19
- 《下一站江湖2》虞令羽之墓开启方法 04-19
- 《下一站江湖2》神刀鬼谕获取方法 04-19