[Solved] Getting output which is not expected while formatting Date from string


It is dd not DD and yy not YY, so change you dateFormat to MM/dd/yy.

let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MM/dd/yy"
print(dateFormatter.date(from: dateString))

0

solved Getting output which is not expected while formatting Date from string