0

Can somebody recommend how to get a current time/date in a specific timezone ?

This is what I got so far:

let date = NSDate()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm"
let str = dateFormatter.string(from: date as Date)


dateFormatter.timeZone = NSTimeZone(name: "UTC") as! TimeZone

print(str)

It gives me my current time, I'm not sure how to change timezone correctly so it would print time in a specified time-zone...

Mike T
  • 53
  • 2
  • 8

0 Answers0