Things to remember: Time Zones.


Okay, here are some things to remember about time zones, jotted out in no particular order.

  • On most modern operating systems, “time” is an absolute quantity, usually measured as the number of seconds from some fixed time in the past, for example, since midnight on January 1, 1970 GMT. This fixed time is called the “epoch.”

This time is an absolute quantity regardless of where you are in the world or how you represent time at your location.

  • Time Zones represent a way by which we represent an absolute time in a human readable format, appropriate for the location where the person is on the Earth.

So, for example, 1,431,385,083 is the number of seconds since our epoch, may be displayed as “May 11, 2015 @ 22:58:03 UTC”, or as “May 11, 2015 @ 6:58:03 PM EST”, or as “May 11, 2015 @ 3:58:03 PM PST”.

While it is easy to think of Time Zones as an offset from GMT, I find that it’s better to treat Time Zones as a sort of “black box”, since the rules as to which time zone offset that applies at a given date can be quite complex. (And if you are in one of the counties in part of Indiana which cannot make up its mind which time zone it wants to be in–EST or CST–the actual rules can be quite arbitrary and bizarre.)

So in a sense a time zone is a thing which converts an absolute number of seconds since epoch, and presents a time suitable for display to the user.

  • When dealing with web applications or mobile applications, the time zone to use when displaying a time depends on the application.

Most of the time, the appropriate timezone to use when displaying a time is the device’s native time zone. Meaning most of the time the default on most platforms is to use whatever time zone the device is in–which is the default when creating classes which display or parse the time.

Sometimes, however, it may be appropriate to display the time in a different time zone. For example, an application that may display the time of an event at a park or for a conference or at a particular movie theater should use the time zone associated with the location of the park or conference or movie theater.

And sometimes I would argue it would be appropriate to display the time twice in two separate time zones. For example, a chat application which notes the sender and receiver of a message are in two different time zones may wish to display the time in the receiver’s time zone and a second time in the sender’s time zone.

Rarely you may need to do something else. For example, an application which tracks an event that happens at the same time of day across multiple dates regardless of the actual time zone. If that is the case, then you may wish to do something other than store the time as an absolute number of seconds and translate to the appropriate time zone.

  • If you ever need to ask for the timezone a user is in–for example, you need to set the preferred time zone for a movie theater–remember: in the United States there are only 10 time zones.

If you look through the IANA Time Zone Database, you may see dozens and dozens of time zones for the United States. But the reality is, there are only 10 time zones that you need to worry about: the nine mentioned in this article, and Arizona, which does not observe daylights savings time.

If the user lives in the areas of Arizona which do observe DST, they can manually select “Mountain Time”; users in Indiana can sort out their own state’s issues.

(Many of the entries in the IANA database deal with historic timezone issues as individual areas of the country tried to sort out which time zone they wanted to be in.)

Similarly Canada has only 6 time zones, and other nations really only observe a handful of time zones.

  • In general, time zones mentioned in the IANA Time Zone database are named after the most populous city in that time zone. Which means if you want to present a more user friendly label you’ll need to roll something which translates between the time zone name and the IANA time zone title.

For example, PST/PDT is actually labeled “America/Los_Angeles”; Los Angeles is the most populous city in the area which observes Pacific Time.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s