How does php calculate the date of birth, age, gender and length of service according to the ID card number?
I would like to share with you how php calculates the date of birth, age, sex and seniority according to the ID card number. I hope you will get something after reading this article. Let's discuss it together.
1. Calculate the date of birth, age and sex according to the ID card number (18 digits)
The copy code is as follows:
/ / 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 gender
If (parseInt (UUserCard.substr (16,1))% 2 = = 1) {
/ / male
} else {
/ / female
}
/ / get 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)