Forum Moderators: coopster

Message Too Old, No Replies

How do I change timestamp to GMT?

         

jezzer300

9:37 pm on Oct 23, 2004 (gmt 0)

10+ Year Member



Hi,

I'm in GMT (UK Time) and my server is in CEST (1 hour ahead).

Is there a setting I can change to use GMT. I want mysql timestamps and php functions to use GMT, and if possible my file date/time stamps too!

I can override php.ini or change .htaccess if necessary. I Don't have access to any other Linux setup from my hosting company.

phpinfo says:
PHP Version 4.3.8
GCI mode
Linux infong 2.4 #1 SMP Mon Aug 9 10:21:08 CEST 2004 i686 unknown

ergophobe

4:17 pm on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The first part is easy. Just use the functions gmdate() [php.net] and gmmktime() [php.net]

The next part is harder since usually it's the OS that sets timestamps on files so you would need to set your server clock to GMT I think.

Tom

mincklerstraat

4:22 pm on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A rather 'klugey' means would be simply to take 60*60 off the unix timestamp each time you either set a date in the db, or display a date. Make sure you get this straight, and only do one of these, or you'll be taking this value off when you put it in the db, and then again when you display it. Even better: put this in a variable in a config file, so you can compensate for such things as possible differences in summer / winter times.

g1smd

5:18 pm on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You said your server is at GMT+1. Your server is NOT in CEST then.

CEST (Central European Summer Time) is GMT+2.
British Summer Time (BST) is GMT+1 used in the UK in Summer.

Beware that some hosts change the server time back by an hour around October, and forward an hour in March or April. (In the Southern hemisphere they move forward in September and backwards in April.) That will mess you up if you assume the server time is constant all year round.

You are best off setting the time to UTC as that IS a constant time zone reference.

GMT (UTC+0000) is used in the UK in Winter.
BST (UTC+0100) is used in the UK in the Summer.

CET (UTC+0100) is used in Central Europe in Winter.
CEST (UTC+0200) is used in Central Europe in Summer.

This list [timeanddate.com] is a very useful reference regarding Daylight Saving Time.