Niklas Karlsson wrote:
Okay, so I should set the default time zone to central GMT time, and then save GMT offset for every user. This sounds realistic, because I don't think that I need to correct the time for users that doesn't login. So, if I now have the GMT offset for every user, how do I display the right date? Can someone please show some phpcode? I would be very grateful if someone could do that.
It depends where the dates are coming from. My guess would be a database, and if so why not let MySQL do the work for you?
SELECT date_created, DATE_SUB(date_created, INTERVAL 8 HOUR) AS offset_date from your_table
The above assumes the users offset is -8 hours. Use DATE_ADD for GMT + values.
Then you'll have both values in PHP - the actual original GMT date the date was created, and an offset date you can use for display.
Or of course you can pluck just the GMT date out and start using PHP functions to convert to local timezones, etc. But if the shoe fits ...
Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk "Never trust a computer you can't throw out of a window" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php