I want to convert the date like "Friday 17th, 7:00pm" this format. but I am unable to add "th" and "st" after the date. I am using below code to convert the date format like this. please tell me. What I do for this format?
func convertDateFormater(_ date: String) -> String
{
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"//this your string date format
dateFormatter.timeZone = NSTimeZone(name: "UTC") as TimeZone?
//dateFormatter.locale = Locale(identifier: "your_loc_id")
let convertedDate = dateFormatter.date(from: date)
guard dateFormatter.date(from: date) != nil else {
assert(false, "no date from string")
return ""
}
dateFormatter.dateFormat = "EEEE dd, h:mma"///this is what you want to convert format
dateFormatter.timeZone = NSTimeZone(name: "UTC") as TimeZone?
let timeStamp = dateFormatter.string(from: convertedDate!)
return timeStamp
}