Forum Moderators: coopster

Message Too Old, No Replies

Timezone Differences

         

username

12:32 am on Oct 21, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi, I am extracting time stamps from my mysql db, and use the following to display the correct local time which works.

putenv("TZ=Europe/Amsterdam");
$date_time = "2009-10-20 10:00:12";

However if someone from the U.S views the time, it will be innacurate because of the GMT + 0200 difference.

How do I detect timezones in PHP then perform the edit to display the time difference? i.e 2009-10-20 08:00:12 which is what it should show in areas of the U.S.

I have considered strtotime, but cannot detect the time zone, nor figure out how to convert back to MYSQL date time stamp.

Thanks.

leadegroot

2:22 am on Oct 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



gmdate may be a function which will help you.
See:
[au.php.net...]
(scroll down for the examples, including the use of an offset)

oh! Interesting! There is a whole new class called DateTime which has been introduced since last time I looked at this stuff!
[au.php.net...]

username

3:09 am on Oct 21, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



No, unfortunately these functions are not what I need. I have looked into getting the timezone in JavaScript, but have been advised that they do not take into account day light savings.

I need to know what timezone I am in, so I can get the offset from GMT, and apply that to my date time.

Any ideas? This is a user by user case on the fly.

username

5:13 am on Oct 23, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



So, no ideas on this?