Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does php calculate the date of birth, age, gender and length of service according to the ID card number?

Shulou Source: shulou.com Published: 2022-05-31 14:33:44 10月02日 Update

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)

Tags: Time age number gender date identity ID card code seniority input month article finished more knowledge results industry information information channel channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno Huawei NVidia Shulou Tech Info