-2

have to extract a separate date and time from the same string i.e)2018-10-23T06:01:10.806Z, the date must be in the format of 10-May-2018 and the time must be in 12 hours format i.e) 08:00 PM

KARTHICK T M
  • 75
  • 1
  • 8

1 Answers1

0

Try this

 func formatDateString(dateString: String) -> Date? {
    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"

    return dateFormatter.date(from: dateString)
}

You get the Date object, do whatever you can do whatever you wanted using that.

Ratul Sharker
  • 7,484
  • 4
  • 35
  • 44