NSTimeZone: Any difference between "UTC" and "GMT"?

Clafou picture Clafou · Feb 19, 2013 · Viewed 18.5k times · Source

Are these five statements interchangeable, or is anyone aware of cases where their use would yield different results? From what I gather they are equivalent but I haven't found anything conclusive, and potential differences between the GMT and the UTC variants worry me.

[NSTimeZone timeZoneWithName:@"GMT"];
[NSTimeZone timeZoneWithName:@"UTC"];
[NSTimeZone timeZoneWithAbbreviation:@"GMT"];
[NSTimeZone timeZoneWithAbbreviation:@"UTC"];
[NSTimeZone timeZoneForSecondsFromGMT:0];

Answer

followben picture followben · Feb 19, 2013

According to the docs, CFTimeZone (and by extension, NSTimeZone) uses time zone names, abbreviations, GMT offset, and DST information from the TZ (or "Olsen") Database.

Looking at the source, you'll see that while semantically "GMT" and "UTC" are quite distinct, in practice they're no different: "GMT" is just a zero offset timezone.

Update: While this answer remains true for dates later than 9 April 1968, when dealing with historical dates, it appears Cocoa uses past definitions of GMT that were valid at the date in question (rather than the modern definition). This means GMT and UTC could differ for dates prior to 9 April 1968. See the end of this informative blog post for a detailed exposition.