tags:

views:

74

answers:

1

I have a list of dates stored in MySQL using PHP.

These were stored using the following code:

date_default_timezone_set('UTC');
$strDate = date("Y-m-d H:i:s",time());

I can only test this from my timezone, which is also UTC!

If a web visitor from eg Eastern Time USA views the page, will the date be converted to UTC correctly?

Presuming that I am storing the UTC dates correctly, what PHP function will display the UTC time, converted to the user's own timezone??

A: 

Firstly you're right to store the UTC; however remember that the date you have in PHP will be the server date - not the client date.

So to continue, read up on how to extract timezone based dates. Then consider how to extract the timezone from the browser - which you will need if you do the local timezone output in PHP rather than on the client.

Richard Harrison