-1

I've read a few similar posts but I can't figure out where I'm still going wrong with the below:

let string = "2015-01-24T08:00"
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-ddTHH:mm"

print(formatter.date(from: string) ?? "Unknown date")

Output is always "Unknown date" (nil)

Thanks!

Sh_Khan
  • 93,445
  • 7
  • 57
  • 76
kingmilo
  • 147
  • 2
  • 11

1 Answers1

1

Change

formatter.dateFormat = "yyyy-mm-dd'T'HH:mm"
Sh_Khan
  • 93,445
  • 7
  • 57
  • 76
  • That did it - thank you! Didn't see anything of the sort for the past hour so hopefully this helps someone else. Appreciate the quick response. – kingmilo Apr 07 '21 at 12:26