25

How do I get the raw offset in milliseconds for Coordinated Universal Time in iOS programmatically?

4

2 回答 2

48
NSInteger millisecondsFromGMT = 1000 * [[NSTimeZone localTimeZone] secondsFromGMT];

In Swift 3 and Swift 4:

let millisecondsFromGmt = 1000 * TimeZone.autoupdatingCurrent.secondsFromGMT()
于 2011-11-18T20:42:42.630 回答
0

Please see answer to my question:

https://stackoverflow.com/a/31988549/3004003

It seems to be more precise regarding expression raw offset, because "raw" actually should mean "without DST at all", like it is in Java (getRawOffset() in java.util.TimeZone class)

于 2015-08-13T15:36:16.713 回答