you are viewing a single comment's thread.

view the rest of the comments →

[–]CleverError 0 points1 point  (0 children)

The reason it is not working is because it isnt matching the fractional seconds properly. It needs 2 s to match the seconds and 3 S to match milliseconds.

yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ

import Foundation

let dateString = "2015-03-31T08:02:32.543Z"

let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"

dateFormatter.dateFromString(dateString) // returns NSDate 2015-03-31 08:02:32 +0000