Reputation: 1952
I'm using Kronos to get date from NTP Servers, the problem is that the returned date is wrong.
Example: The time in my country is 2019-2-2 20:22:05 +0000 but what i get is 2019-2-2 22:22:05 +0000
I think It's about the timezone, but i couldn't reach it
Thanks.
Upvotes: 0
Views: 785
Reputation: 1952
I wrote some code to make it right
Clock.sync { date, offset in
let dateFormatter = DateFormatter()
dateFormatter.calendar = NSCalendar.current
dateFormatter.timeZone = TimeZone.current
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let dt = dateFormatter.string(from: date!)
dateFormatter.timeZone = TimeZone(abbreviation: "UTC")
print(dt)
}
Upvotes: 2