Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
203 views
in Technique[技术] by (71.8m points)

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

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];
question from:https://stackoverflow.com/questions/14947213/nstimezone-any-difference-between-utc-and-gmt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...