Unfortunately, there isn't always a single timezone for each GMT offset. Many GMT offsets have multiple timezones. Also, GMT offsets change during DST (where applicable). For instance, during DST, US/Arizona and US/Mountain share the same GMT offset; however, during the rest of the year, US/Mountain
and US/Arizona
don't share the same GMT offset. You can either use DateTimeZone::listIdentifiers()
or check out the manual for a list of supported timezones in PHP.
If you were starting an application from scratch, I would suggest storing the timezone identifier instead of the GMT offset, but I'm guessing your application is already in production. In that case, there's not really a reliable way to display the timezone without improving your data.
I would suggest that you add a timezone
column to the table. You could write a one-time script that would set the timezone
to some pre-defined list of defaults based on the GMT offset. For instance, if the GMT offset is 8, set the timezone
to America/Los_Angeles
. Finally, change your application to display/save timezone identifiers instead of GMT offsets. This may cause problems for a subset of your users, but it allows them to change their timezone if they need to.