How can i calculate year from entering my age using php.

example:

i am entering my age as 24.

So that i need to get the year as 1985.

how this can be done.

thanks in advance

Comments

just we need the year 1986 animuson. In this case we don't need to care of Month and Year. Is there any way

Written by Fero

Accepted Answer

If you knew simple math, you'd know that 2010 - 24 - 1 = 1985 or $year = date("Y") - $theirage - 1... But just giving an age does not accurately deduce what year they were born. For example:

If the date is December 30, 2010 and they say they're 24, you're still saying they were born in 1985 when chances are very, very high that they were actually born in 1986. You cannot rely on their age to give you their birth year.

EDIT If that wasn't very clear:

Today's date is June 16, 2010. So to be 24 years old, I would have needed to be born somewhere between June 17, 1985 and June 16, 1986. That's near half of the birthyears that would be 1985 and near half that would be 1986, causing a very high inaccuracy.

Written by animuson
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki