I'm getting a date back from an API in the following string format: "2021-09-12T17:00:00.000Z". This seems to be a variation on ISO8601 or RFC3339 but I'm having trouble parsing it with ISO8601DateFormatter(). Can you tell me the correct format options for ISO8601DateFormatter(), or provide a workaround for this date format?
Example Code:
let dateString = "2021-09-12T17:00:00.000Z"
let formatter4 = ISO8601DateFormatter()
formatter4.formatOptions = [.withInternetDateTime]
print(formatter4.date(from: dateString) ?? "Unknown date")
I get Unknown date with this every time. I've not had luck with other options either.