Skip to content

Instantly share code, notes, and snippets.

@atika
Created March 10, 2016 09:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atika/ec4b158c40d1f71a200b to your computer and use it in GitHub Desktop.
Save atika/ec4b158c40d1f71a200b to your computer and use it in GitHub Desktop.
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(tz.name) // 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