Swift 3 timezone issue
Try like this.
TimeZone.ReferenceType.default = TimeZone(abbreviation: "BST")!
Edit: I have used this TimeZone
with DateFormatter
and get the correct BST
time with date.
TimeZone.ReferenceType.default = TimeZone(abbreviation: "BST")!
let formatter = DateFormatter()
formatter.timeZone = TimeZone.ReferenceType.default
formatter.dateFormat = "yyyy-MM-dd HH:mm"
let strDate = formatter.string(from: Date())
print(strDate)
If you want to set defaultTimeZone
for NSTimeZone
object then in Swift 3 you can set like this.
NSTimeZone.default = TimeZone(abbreviation: "BST")!
let locale = NSTimeZone.init(abbreviation: "BST")
NSTimeZone.default = locale as! TimeZone
Try this