I have a server which is set to EST, and all records in the database are set to EST. I would like to know how to set it to GMT. I want to offer a time zone option to my user
It is important to note that if you are using date('Z') to convert a date that is stored in a database that you give the date the timestamp as the second argument, otherwise your result will not be accurate.
e.g.
In the UK, sometimes date('Z') will give 3600, sometimes it will give 0.
echo date('Z', strtotime('2012-01-01'));
Gives 0
echo date('Z', strtotime('2012-07-01'));
Gives 3600
So purely using strtotime($dbDateValue) - date('Z') can be wrong
Instead use:
$dbDateTimestamp = strtotime($dbDateValue); // where $dbDateValue something like 2012-01-01 22:34:00
$utcTimestamp = strtotime($dbDateTimestamp) - date('Z', $dbDateTimestamp);
This of course relies on PHP and the database both being set to the same timezone.