我有一个想要转换为日期的字符串,但是在代码下面,
那str
打印出来Optional(2016-04-25 17:00:16 +0000)
我想知道如何准确显示Optional(2016-04-26T03:00:16.047)
var str = "2016-04-26T03:00:16.047"
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"//this your string date format
dateFormatter.timeZone = NSTimeZone(name: "UTC")
let date = dateFormatter.dateFromString(str)
print(date) //Optional(2016-04-25 17:00:16 +0000)