I have the following date string:
let dateString = "2018-06-24T14:52:32.647Z"
I'm trying to turn it into a date. However, it's not working with my DateFormatter
.
I have extended DateFormatter to give a static formatter that I use throughout my app:
extension DateFormatter {
static let formatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
return formatter
}()
}
Then I say:
let date = DateFormatter.formatter.date(from: dateString)
It returns nil
on one of my devices, but works on the rest of them. What am I doing wrong? Is it because I have three Z
s at the end and I should have one?