Applies to the management of archives in OA projects.
1. Calculate the birth date, age, and gender (18 digits) based on the ID card number)
CopyCodeThe Code is as follows: // obtain the ID card number
VaR uusercard = $ ("# uusercard"). Val ();
// Obtain the Date of birth
// Uusercard. substring (6, 10) + "-" + uusercard. substring (10, 12) + "-" + uusercard. substring (12, 14 );
// Obtain gender
If (parseint (uusercard. substr (16, 1) % 2 = 1 ){
// Male
} Else {
// Female
}
// Obtain the 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 (10, 12) <month | uusercard. substring (10, 12) = month & uusercard. substring (12, 14) <= day ){
Age ++;
}
// Age
2. Calculate the length of service based on the start time Copy codeThe Code is as follows: // get the input entry time and convert it to date
VaR utotime = $ ("# utotime"). Val ();
VaR adate = utotime. Split ("-");
// Because the month value ranges from 0 to 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 ();
// Subtract time to get the millisecond Value
VaR DIF = mydate. gettime ()-newdate. gettime ();
Mydate. settime (DIF );
// The result is [May 29 ].
// Mydate. getfullyear ()-1970 + "year" + mydate. getmonth () + "month" + mydate. getdate () + "day"
Author: lying. net