最新下载
热门教程
- 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-30
- 我的勇者游侠怎么搭配最强 04-30
- 仙剑世界照影迷妄镜任务流程完整解析 04-30
- CF手游王者风神保底价格攻略 04-30
- 明日之后前期装备推荐依据分享 04-30
- 明日之后菊花瓣食谱怎样 04-30