处理身份证获取用户的年龄

        处理身份证获取用户的年龄

 

 


    testAge(idcard ) {           let birthday;       let nowDay = new Date();       // birthday = idcard.substr(6,4)       let birthdayYaer = idcard.substr(6, 4);       let birthdayMonth = idcard.substr(10, 2);       let birthdayDay = idcard.substr(12, 2);       birthday = birthdayYaer + "-" + birthdayMonth + "-" + birthdayDay;       let birthdays = new Date(birthday.replace(/-/g, "/"));       let age =         nowDay.getFullYear() -         birthdays.getFullYear() -         (nowDay.getMonth() < birthdays.getMonth() ||         (nowDay.getMonth() == birthdays.getMonth() &&           nowDay.getDate() < birthdays.getDate())           ? 1           : 0);           return age;     },
上一篇:android 2.2,2.3 webview 无法弹出系统软键盘


下一篇:封装公共函数