25

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

Suchi
  • 9,989
  • 23
  • 68
  • 112

2 Answers2

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

In Swift 3 and Swift 4:

let millisecondsFromGmt = 1000 * TimeZone.autoupdatingCurrent.secondsFromGMT()
rob mayoff
  • 375,296
  • 67
  • 796
  • 848
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)

Community
  • 1
  • 1
schmidt9
  • 4,436
  • 1
  • 26
  • 32