Page 1 of 1

calculate person's birthdate using age

Posted: Thu May 28, 2009 1:13 am
by chelflores
is it possible to compute the birthdate of person using age??
can anyone help me on this..thanks....

Re: calculate person's birthdate using age

Posted: Thu May 28, 2009 1:25 am
by anand
chelflores wrote:is it possible to compute the birthdate of person using age??
can anyone help me on this..thanks....
We can get one's birth year using his age. not birth day. But there might be some chances of error as well.

For an example, I am 21. So, my birthday should be at 2009-21 = 1988 whereas, its in 1987.

Anyways, you can do this.

Code: Select all

 
 
$age = $_POST['age']; // Age of the user
 
$Time_Passed_Since_He_Was_Born = 60*60*24*365*$age; // Present time minus time since he was born. 60 sec * 60 min * 24 hrs * 365 days * his age.
 
$Year_Of_Birth = time() - $age;
 
echo date("Y", $Year_Of_Birth);   
 
 
I hope this will help you.