What is a Time Zone?

Almost any time you call up a friend, relative, or business associate in another part of the world, you'll realize that your time isn't always the same as their time, and the reason is "time zones".  You probably know a little about time zones already, but just what exactly is a time zone anyway?  Is "EST" a time zone?  What about "GMT-8", is that a time zone?  How does daylight saving time fit into it?  And just how many time zones are there?

In this article, I'll answer all of these and more.  You'll learn how time zones behave in the real world, and how they are used in computing.

Pluralsight
This material is also covered in my Pluralsight course, Date and Time Fundamentals. If you enjoy this topic, please consider watching the video course!

A time zone is a geographic region

When talking about time zones, it's important to recognize that you are talking about a real place on the surface of the Earth.  Within the boundaries of a time zone, all local clocks should follow the same set of timekeeping rules.  Usually these rules are set by the laws of that region.  However, there are also time zones that are in place by convention, without any governing laws.

Time Zone != Offset

A time zone is not just an offset from UTC or GMT.  An offset is simply one characteristic of a time zone.  In fact, many time zones have two offsets - one that is followed during "standard time", and one that is followed during "daylight time" (which is sometimes called "summer time").  Therefore, a time zone cannot be represented by just a single number.

Time Zone Characteristics

A time zone consists of all of the following:

  • A geographic boundary that can usually be plotted on a map
  • A legal name (or a common name), such as "Eastern Time"
  • One or more rules which consist of:  The effective date and time for the rule A standard offset from UTC, such as UTC-5 If the time zone uses daylight saving time:  The daylight offset, such as UTC-4.  This is usually (but not always) one hour greater than the standard offset. The transition dates and times that daylight saving time starts and ends    

Each offset within the rule will usually have an associate name and abbreviation.  For example, in the US Eastern Time zone, UTC-5 is associated with "Eastern Standard Time" and abbreviated "EST".  Likewise, UTC-4 is associated with "Eastern Daylight Time" and abbreviated "EDT".

Time Zones of the Continental United States

Time zones can change!

The reason more than one rule can exist is simple: Governments often change their minds!  Whenever a government decides that their time zone should either move to a different base offset, enact or rescind daylight saving time, or change the transition dates of when daylight saving time begins or ends, the existing rule becomes invalid, and a new rule goes into effect.  You may not realize it, but this happens all over the world, dozens of times every year!

Time Zones in Computing

In order to keep track of the complexities of the world's time zones, most computer operating systems and software applications use one of the following two common data sources.

The IANA Time Zone Database

iana.org/time-zones
This is the oldest and most comprehensive source of time zone information publicly available on the Internet.  It is maintained in the open, by a group of volunteers.  It is also known as the "Olson" database, after one of its founding members, Arthur David Olson.  Sometimes it is also just called the "tz database", "tzdb", or "zoneinfo".

In this database, time zones are identified with a name consisting of an Area and a Location, separated by a forward slash.  For example, "America/New_York", or "Europe/London".

The IANA database has data on all the time zones of the world, going back to at least 1970.  In many cases, it has information for years much earlier.

This database is used in many projects, including Linux, Mac OSX, iOS, and Android operating systems, the Java and PHP runtime environments, Oracle, PostGres, and MySQL databases, and various libraries for just about any programming language you can think of.

It is updated frequently, whenever new information is discovered about the worlds ever-changing time zones.  There are usually about a dozen updates per year.  Anyone can participate in this effort, by joining their mailing list.

There are over 400 time zones in this database (over 500 if you count aliases).  These are shown on the following world map.

Map of IANA time zones

The Microsoft Time Zone Database

microsoft.com/time
Of all the operating system vendors, only Microsoft maintains its own list of time zones.  These are used by the Windows operating system, and are also exposed through the TimeZoneInfo class in the .NET Framework.  Because of this, you will also see them in the user settings on various web sites by Microsoft, and by others that build their sites using the .NET Framework.

Microsoft time zones are identified by the registry key in which they are found in Windows, as seen below:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones

Time Zone Registry Keys

In .NET, the registry key name corresponds to the Id property of the TimeZoneInfo class.

Each time zone also has a Display Name.  For example, the "AUS Eastern Standard Time" time zone has the display name of "(UTC+10:00) Canberra, Melbourne, Sydney".  These names are shown when choosing a time zone in the Windows control panel, and they are localized to the language of the operating system.

Windows time zones are maintained solely by Microsoft, and are updated much less frequently than IANA time zones.  There are usually two cumulative updates per calendar year, and a small number of hotfixes in between.  Most of the time, only the cumulative updates are applied automatically by Windows Update.  The hotfixes must be installed manually.

There are currently 107 Microsoft time zones.  In general, they tend to cover more area than the IANA time zones.  They can do this, because they have less history in them.  The typical Microsoft time zone entry either has no historical data at all, or has it only going back to 2010.  The earliest historical information in the Microsoft dataset is for 2004, and there is little consistency about which time zones have history and which do not.

There are also many errors and limitations of this dataset.  In general, it serves the purpose of keeping the local time on the computer accurate, and it lets developers work with relatively recent timestamps in their applications.  But it doesn't do much more than that - at least not very well.

Other Differences
  • IANA time zone names follow a standard convention, while Microsoft time zones seem to have several different intermingled naming conventions, and some made up names (ex. "Romance Standard Time").
  • IANA implements its time zones based on reported information from what is actually in effect and used by people in the region.  Microsoft implements only official time zones that are set by legislation or other official government policy.  In many cases this aligns, but in some cases it doesn't.
  • Microsoft time zones can only implement two DST transitions in a given year, so they have problems representing real-world scenarios, like when Egypt and Morocco switched four times in a single year.

Advice for .NET Developers

While many applications can get by using the Microsoft time zones exposed by the TimeZoneInfo class, you should consider if your application may benefit from working with IANA time zones instead.

For .NET, the easiest way to work with IANA time zones is to use the Noda Time open source library.  This library also offers an API for working with dates and times that is in many ways superior to the types built-in to the .NET Framework.

// Example using Noda Time to get the current local time in Japan
Instant now = SystemClock.Instance.Now;
DateTimeZone tz = DateTimeZoneProviders.Tzdb["Asia/Tokyo"];
ZonedDateTime zdt = now.InZone(tz);

Another open source library that you may find useful is one of my own creation.  The TimeZoneNames library can be used to get the localized names and abbreviations for any time zone.  It works with either IANA or Microsoft time zone ids, so you can use it with or without Noda Time.

// Example code to get the English names for the Pacific time zone
var names = TimeZoneNames.GetNamesForTimeZone("America/Los_Angeles", "en-US");

names.Generic == "Pacific Time"
names.Standard == "Pacific Standard Time"
names.Daylight == "Pacific Daylight Time"
// Example code to get the French names for the Pacific time zone
var names = TimeZoneNames.GetNamesForTimeZone("America/Los_Angeles", "fr-CA");

names.Generic == "heure du Pacifique"
names.Standard == "heure normale du Pacifique"
names.Daylight == "heure avancée du Pacifique"
// Example code to get the English abbreviations for the
// Australian Eastern time zone (Microsoft ID)
var abbreviations = TimeZoneNames.GetAbbreviationsForTimeZone("AUS Eastern Standard Time", "en-US");

abbreviations.Generic == "AET"
abbreviations.Standard == "AEST"
abbreviations.Daylight == "AEDT"

It also includes functions to return the time zones applicable for a given country, so it is useful when building time-zone selection controls.  (A common technique for time zone selection is to first pick a country, and then pick a zone within the country if the country has more than one time zone.)

More to follow!

If you enjoyed this post, stay tuned to my blog, as I will be posting additional fun facts about time zones, and other interesting topics about dates and times.  Remember, you can find all of this and more in my Pluralsight video course, Date and Time Fundamentals.