Calculate age (jQuery or PHP) based on date of birth [not based on user input]

后端 未结 4 761
青春惊慌失措
青春惊慌失措 2021-01-16 04:27

I am looking for a JavaScript or PHP script that allows me to calculate somebody\'s age based on his/her date of birth in the mm/dd/yyyy format. I found this ve

4条回答
  •  时光说笑
    2021-01-16 04:58

    Easiest way to calculate age is:

    CURRENT YEAR - BIRTH YEAR = AGE  
    IF(CURRENT MONTH DAY < BIRTH MONTH DAY) AGE--;
    

    I.E. Years alive but -1 if you haven't had a birthday yet

    MONTH DAY is 0301 for 1st March

提交回复
热议问题