calculate person's birthdate using age

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chelflores
Forum Newbie
Posts: 8
Joined: Tue Jun 24, 2008 7:00 pm

calculate person's birthdate using age

Post by chelflores »

is it possible to compute the birthdate of person using age??
can anyone help me on this..thanks....
anand
Forum Commoner
Posts: 80
Joined: Fri May 22, 2009 11:07 am
Location: India
Contact:

Re: calculate person's birthdate using age

Post 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.
Post Reply