How to Convert MYSQL DateTime to NSDate - Swift [duplicate]
问题 This question already has an answer here : How to convert MySQL datetime to NSDate? (1 answer) Closed 4 years ago . "2015-06-30T17:30:36.000Z" is an example of DateTime value in MySQL. How to convert it to NSDate in Swift? Below is my code but it does not work var sqlDateFormatter = NSDateFormatter() sqlDateFormatter.dateFormat = "yyyy’-‘MM’-'dd’T'HH’:'mm’:'ss'Z’" self.whenPublished = self.sqlDateFormatter.dateFromString("2015-06-30T17:30:36.000Z") 回答1: You just need to add the milliseconds