Created
March 10, 2016 09:59
-
-
Save atika/ec4b158c40d1f71a200b to your computer and use it in GitHub Desktop.
NSTimeZone tests and change app default TimeZone in Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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