iOS - How to get raw offset for timezone?

怎甘沉沦 提交于 2019-12-20 16:35:14

问题


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


回答1:


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

In Swift 3 and Swift 4:

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



回答2:


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)



来源:https://stackoverflow.com/questions/8188818/ios-how-to-get-raw-offset-for-timezone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!