john
john

Reputation: 35400

Is there a simple way to present timezone options while still maintaining accurate timezone conversions?

I'm a little confused as to how we should handle timezone conversions.

We are building a website that has scheduled shows, and want to show the user the correct show time based on their selected timezone.

The timezone values we are using are coming from

select * from tz_zone order by zone_name asc;

Sample values look like this:

Africa/Abidjan
...
America/Antigua
America/Araguaina
America/Argentina/Buenos_Aires
America/Indiana/Indianapolis
America/Los_Angeles
...
Antarctica/Casey
...
Asia/Aden
...
Atlantic/Azores
...
Europe/Andorra
...

As you can see, these values are not easy for people to understand.

Traditionally, we see things simplified lists like -8:00 UTC for Pacific and I think people generally understand that, but I'm a little confused as to how that works.

When we look at things like DST, we know that not every place observes it (e.g., Arizona, etc.)

To do our timezone conversions, we store the data in UTC and run something along the lines of:

select convert_tz(show_time, 'UTC', 'America/Los_Angeles') as show_time from shows

For a state like California that does observe DST, part of the year they would be -8 and then part of the year they would be -7. If we store the value as -8, does that imply that half the year, they are getting the wrong show times?

Upvotes: 0

Views: 38

Answers (1)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241693

If you only store -8, then the part of the year that follows daylight saving time would be getting the wrong times.

The specific dates and times of the daylight saving transition points are often different for each time zone. If you want the actual behavior of the US Pacific time zone, then you must use "America/Los_Angeles".

See also "Time Zone != Offset" in the timezone tag wiki.

If you're looking for a more intuitive way for the user to select their time zone, consider a map-based time zone picker, such as this one or this one.

Upvotes: 2

Related Questions