Suchi
Suchi

Reputation: 10039

iOS - How to get raw offset for timezone?

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

Upvotes: 25

Views: 10761

Answers (2)

rob mayoff
rob mayoff

Reputation: 385540

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

In Swift 3 and Swift 4:

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

Upvotes: 48

schmidt9
schmidt9

Reputation: 4528

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)

Upvotes: 0

Related Questions