码迷,mamicode.com
首页 > Web开发 > 详细

JS通过身份证号码获取出生年月日

时间:2016-06-14 19:11:09      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:

getBirthdayFromIdCard : function(idCard) {  
        var birthday = "";  
        if(idCard != null && idCard != ""){  
            if(idCard.length == 15){  
                birthday = "19"+idCard.substr(6,6);  
            } else if(idCard.length == 18){  
                birthday = idCard.substr(6,8);  
            }  
          
            birthday = birthday.replace(/(.{4})(.{2})/,"$1-$2-");  
        }  
          
        return birthday;  
      },  

// 实例

425125198808083000

// 结果

1988-08-08

JS通过身份证号码获取出生年月日

标签:

原文地址:http://www.cnblogs.com/lr393993507/p/5584888.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!