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

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

posted @ 2016-06-14 17:50  魔流剑  阅读(16775)  评论(0编辑  收藏  举报