For showing date in local time zone we need to use DateFormatter class and set to it our local time zone:
let date = Date()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd.MM.yyyy HH:mm"
let localTZ = TimeZone.current
dateFormatter.timeZone = localTZ
print(localTZ.abbreviation())
self.userLastTimeRefreshedLabel.text = String("\(dateFormatter.string(from: date))")
No comments:
Post a Comment