怎么用js抽取身份证号中的年份?具体怎么实现

2021-04-19 17:51发布

3条回答
羊羊羊羊
2021-04-21 15:54
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;  
      },


一周热门 更多>