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
Asked
Active
Viewed 75 times
-2
-
show your tried code – Anbu.Karthik Oct 23 '18 at 06:10
-
No one will write code for you. Please elaborate which kind of error are you facing? What have you done to achieve your desired output? – Mrugesh Tank Oct 23 '18 at 06:17
1 Answers
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