I have this type of string, "2019-03-22", and want to convert it to this string, "March 22, 2019", in Swift.
It looks simple and I tried a few different ways. But I haven't figured it out yet.
The best code I have is this:
let originalDate = "2019-03-22"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MMMM dd, yyyy"
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
let newDate = dateFormatter.string(from:originalDate)!
print(newDate)
But I get this error Cannot convert value of type 'String' to expected argument type 'Date'
How do I fix this?