php根据身份证号码计算年龄

我们只要知道身份证的生成规则就可以了,像下面我们从指定位置到多少位就是出日期了,然后我们把日期转成时间戳然后进行加减运算就得出了年龄了,下面我们看实例代码如下:

  1. <?php  
  2. function getAgeByID($id){  
  3.          
  4. //过了这年的生日才算多了1周岁  
  5.         if(emptyempty($id)) return '';  
  6.         $date=strtotime(substr($id,6,8)); 
  7. //获得出生年月日的时间戳  
  8.         $today=strtotime('today'); 
  9. //获得今日的时间戳  
  10.         $diff=floor(($today$date)/86400/365); 
  11. //得到两个日期相差的大体年数  
  12.          
  13. //strtotime加上这个年数后得到那日的时间戳后与今日的时间戳相比  
  14.         $age=strtotime(substr($id,6,8).' +'.$diff.'years')>$today?($diff+1):$diff;  
  15.    
  16.         return $age;  
  17.     }  
  18. ?> 
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » php根据身份证号码计算年龄

130 评论

  1. tacrolimus 1mg usa urso generic urso 300mg drug

  2. purchase dapoxetine pills priligy generic buy synthroid 100mcg generic

  3. order methotrexate 10mg generic methotrexate oral order reglan online cheap

  4. trazodone 100mg drug suhagra usa order sildenafil 50mg online cheap

  5. order lasix 100mg online cheap brand doxycycline hydroxychloroquine 400mg usa

  6. order singulair without prescription order viagra pill usa viagra overnight

  7. order coreg 6.25mg generic elavil 10mg uk generic amitriptyline

  8. buy prednisone 20mg without prescription generic prednisone order amoxil 1000mg pills

  9. cost modafinil 100mg buy lisinopril buy metoprolol sale

  10. example of introductory paragraph with thesis statement writing a graduate thesis how to start a thesis statement example

  11. how to write a thesis for a literary analysis thesis help turner thesis apush

  12. buy avlosulfon 100mg online asacol 400mg pill order atenolol 50mg pill

  13. alfuzosin 10 mg us desyrel cost order diltiazem 180mg

  14. zetia online ezetimibe price order methotrexate 5mg generic

  15. femara 2.5 mg over the counter order viagra buy viagra 100mg for sale

  16. tadalafil alternatives tadalafil 20 mg taking tadalafil and sildenafil together

  17. buy imitrex 50mg for sale avodart 0.5mg us buy dutasteride without a prescription

  18. norvasc drug interactions buy norvasc amlodipine vs nifedipine

  19. purchase estradiol generic lamictal price prazosin 1mg drug

  20. what are side effects of zoloft sertraline for how does zoloft work

  21. how long does it take seroquel to kick in seroquel effects quetiapine n 200

  22. buy ivermectin canada cost stromectol 6mg order deltasone 20mg without prescription

  23. buy furosemide for sale vibra-tabs us ventolin 4mg uk

  24. asacol brand avapro online buy irbesartan 150mg pills

发表评论

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡