I'm trying to convert a date string from yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
to "day, date month year", something like this "Monday, 01 January 2018".
I'm using my helper function which converts a date string from one format to another. In the function below I'm not sure what parameter needs to be passed for to
:
func convertDate(from inputFormat: String, to outputFormat: String) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = inputFormat
if let dateInLocal = dateFormatter.date(from: self) {
dateFormatter.dateFormat = outputFormat
dateFormatter.amSymbol = "AM"
dateFormatter.pmSymbol = "PM"
return dateFormatter.string(from: dateInLocal)
}
return "NA"
}
Using above extension like below
dateAndName = date.convertDate(from:"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", to: "")