Jump to content

Calculating age from date of birth. Also time zone issues.


pthurmond

Recommended Posts

Are there any functions for calculating someones age from their date of birth in php? I don't suppose it would be as easy as subtracting their date of birth from the current date.

Also I need to be able to record time from the users time zone for signin times. Any suggestions as to how to get the time for their time zones?

Oh and does php have any pre-designed functions to convert time from the hour:min AM/PM format to military time?


Thanks,
Patrick
Link to comment
Share on other sites

All your answers are here:

http://sg.php.net/manual/en/ref.datetime.php

I would recommend checking out date() and strtotime(), and have a read of the comments below.  Many people have posted useful code in the comments.

Edit: As for time zones, the forum software I've seen asks the user for their time zone on registration :)  A lot try to guess the time zone with geolocation stuff, which I know little about.. but it seems quite effective.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.