0

I have a date string in the following format "2017-02-10T07:45:00.000Z"

I am using the following format let flightStatusDateFormat = "yyyy-MM-ddTHH:mm:ss.SSSZ"

But when I run the app the dateFormatter returns a nil NSDate object. Any help is appreciated.

Thanks

Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115

2 Answers2

3

It should be,

let flightStatusDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
Ro4ch
  • 850
  • 8
  • 21
0

Please escape the T and the Z:

let flightStatusDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

If you don't, the Z will be considered as the TimeZone, and the T will be unrecognized.

Dean
  • 1,512
  • 13
  • 28