The birth date, age, and gender (18 digits) are calculated based on the ID card number, and the length of service is calculated based on the start time.

Source: Internet
Author: User

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)
// Obtain the input ID card number var uusercard =$ ("# uusercard "). val (); // get the date of birth // uusercard. substring (6, 10) + "-" + uusercard. substring (10, 12) + "-" + uusercard. substring (12, 14); // obtain the gender if (parseint (uusercard. substr (16, 1) % 2 = 1) {// male} else {// female} // 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 (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
1 // convert the entry time to date 2 var utotime = $ ("# utotime "). val (); 3 var adate = utotime. split ("-"); 4 // because the month value is 0-11, here we subtract the input month by 5 var newdate = new date (adate [0], adate [1]-1, adate [2]); 6 // current time 7 var mydate = new date (); 8 // Subtract time to get the millisecond value 9 var DIF = mydate. gettime ()-newdate. gettime (); 10 mydate. settime (DIF); 11 // The result is 12 // mydate. getfullyear ()-1970 + "year" + mydate. getmonth () + "month" + mydate. getdate () + "day"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.