iOS - How to get raw offset for timezone?

Suchi picture Suchi · Nov 18, 2011 · Viewed 10.5k times · Source

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

Answer

rob mayoff picture rob mayoff · Nov 18, 2011
NSInteger millisecondsFromGMT = 1000 * [[NSTimeZone localTimeZone] secondsFromGMT];

In Swift 3 and Swift 4:

let millisecondsFromGmt = 1000 * TimeZone.autoupdatingCurrent.secondsFromGMT()