Our server is set to GMT time so the hour does not keep jumping around in spring and autumn. However, during summer time, it is annoying that all the times are displayed an hour out.
How do I get and display the time, taking into account the local timezone in PHP (especially when the server thinks the local timezone is GMT).
or, How do I know if an area is using "summer time" at the moment?
or, How do I display a GMT time stamp or a different timezone?
You can use the date function to offset GMT
get the date/time and first check to see if the month (split on dashes if its a DATETIME field) is a 'summer month', or a month that will cause the time to be an hour out.
If so, convert it to a unix timestamp. Then, add (or minus, whichever way it is out) 60 * 60 (60 mins) to the timestamp and convert into a human readable format.
Problem solved!
Easiest way to display local time is to use JavaScript:
Actually, I think I may have found the answer I need...
The PHP manual entry is here:- http://us2.php.net/manual/en/function.date-default-timezone-set.php
You could add this line in PHP:
And every subsequent call to time()/date() will give you the time in your time zone.
List of time zones
This code will display the current time in the Eastern time zone (US):