Skip to content
Advertisement

How to calculate the age of a person using variables like: year, month, day in PHP

I have tried to get the age of a person, using the code below, although I wanted the output to be your exact age, it reads an incorrect age if your birthday was before the current date but a correct age if your birthday is after the current date kindly correct the code

JavaScript

Advertisement

Answer

You can use this for age calculation:

JavaScript

Update:
So the whole code with some cleanup will be like:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement