1, according to the ID number calculation date of birth, age, sex (18-digit)
Copy Code code as follows:
Get input ID number
var Uusercard = $ ("#UUserCard"). Val ();
Get Date of birth
Uusercard.substring (6) + "-" + uusercard.substring (a) + "-" + uusercard.substring (12, 14);
Access to gender
if (parseint (Uusercard.substr (16, 1))% 2 = 1) {
Man
} else {
Woman
}
Get age
var mydate = new Date ();
var month = Mydate.getmonth () + 1;
var day = Mydate.getdate ();
var age = Mydate.getfullyear ()-uusercard.substring (6, 10)-1;
if (uusercard.substring < month | | Uusercard.substring = = Month && uusercard.substring (a) <= day) {
age++;
}
Age
2. Calculate the seniority according to the entry time
Copy Code code as follows:
Gets the entry time for the conversion to date
var utotime = $ ("Utotime"). Val ();
var adate = Utotime.split ("-");
Because the month value is 0-11, the input month is reduced by one
var newdate = new Date (adate[0], adate[1]-1, adate[2]);
Current time
var mydate = new Date ();
Time subtraction to get millisecond value
var dif = Mydate.gettime ()-newdate.gettime ();
Mydate.settime (DIF);
The result is "1 years May 29"
Mydate.getfullyear ()-1970 + "Year" + mydate.getmonth () + "month" + mydate.getdate () + "Day"