-3

I am working in Swift language. I don't know the date format for this 2020-07-23T00:17:06.000Z.

I want to convert Date to String by following that format & vice versa.

How can I do? Thanks in advance...

Mount Ain
  • 316
  • 3
  • 15
  • https://stackoverflow.com/questions/28016578/how-to-create-a-date-time-stamp-and-format-as-iso-8601-rfc-3339-utc-time-zone/28016692#28016692 – Leo Dabus Jul 24 '20 at 03:58

1 Answers1

3

it is iso8601

let string = "2020-07-23T00:17:06.000Z"
let dateFormatter = ISO8601DateFormatter()
dateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
let date = dateFormatter.date(from: string)
Horst
  • 1,733
  • 15
  • 20