0

Hi guys, i have been trawling around looking for a decent and simple way of working out an age from a birthday.

The way i'm working is a date of birth is added to a database then when pulled we echo the actual age and not the d.o.b.

It's probably quite simple but i can't seem to figure it out, Also there may not be an actual day eg 06/2009 instead of 13/06/2009 if you see my meaning.

Any direction would be great!

Thanks again...

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by EvolutionFallen
1

How about converting the date string into a UNIX timestamp, then subtracting that stamp from today's stamp?
Something like:

$b_day = strtotime("1/1/1970"); // UNIX time for birthday
$today = strtotime(date("m/d/Y"));
$age = date("your formatting string here", $today - $b_day));
0

Should be clear from the next row but if not:

b_day = strtotime("1/1/1970") //is also in m/d/Y (US) format

@EF - sorry for jumping in.

0

You're welcome emhmk1.
No problem ardav =) I was in a rush so I was worrying more bout typing the code than placing comments. Thanks for filling it in.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.