I have Swift 5 and such date string:
let dateString = "2019-11-09T08:14:09.361404Z"
and two approaches to convert it to date:
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'"
let date = dateFormatter.date(from: dateString)
let dateFormatter = ISO8601DateFormatter()
dateFormatter.formatOptions = [.withFractionalSeconds, .withInternetDateTime]
let date = dateFormatter.date(from: dateString)
as result:
first case: 2019-11-09 05:14:09 +0000
second case: 2019-11-09 08:14:09 +0000
Dates differ by 3 hours (just like my timezone differs from GMT). Setting the timezone to my current both formatters doesn't affect the results.
Could you please explain difference and which result is correct?