Help - Search - Members - Calendar
Full Version: Using PHP to work out someone's age from their DoB
Invision Power Services > Community Forums > Community Web Design and Coding
Reado
I'm looking for a simple script that can determine how old someone is by taking into account their Date of Birth. The PHP website has an example on the "date" section, but I don't understand it.

Doesn't anyone else have any scripts or examples?

Thanks.
_
If you have it as a UNIX timestamp, it's fairly easy to do. Just time() - $timestamp. Otherwise, you can make a timestamp with the PHP function 'mktime' (search).
Μichael
There is a mod at Invisionize that takes the user's birthday as entered into their profile and displays their age below their posts. You could use much of the same code there to do this calculation for your purposes.
princetontiger
If you are using something other than IPB, it will largely depend on how you store the user's birthday.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.