Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
NSTimeZone tests and change app default TimeZone in Swift
let tz = NSTimeZone.init(forSecondsFromGMT:3600)
NSTimeZone.setDefaultTimeZone(tz) // Change app default timezone
print(tz) // GMT+0100 (UTC+1) offset 3600
print(NSDate()) // 2016-03-10 09:57:44 +0000
print(tz.abbreviation) // Optional("UTC+1")
print( // GMT+0100
print(tz.description) // GMT+0100 (UTC+1) offset 3600
print(tz.localizedName(.Standard, locale:NSLocale.currentLocale()) ) // Optional("UTC+01:00")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment