this question has answer here:
- nsdateformatter returns nil 2 answers
lastreviewdate = "2016-06-06t20:24:15.9313557z"
var formatter = nsdateformatter() formatter.dateformat = "yyyy-mm-ddthh:mm:ss.ssssssz" let date = formatter.datefromstring(lastreviewdate)
date returns nil. why happening, looks format matches string exactly.
"hh" used or pm, if want use 0-23 hour , have use "hh" or want 1-24 hour use "kk"
use dateformat string work
"yyyy-mm-dd't'hh:mm:ss.ssssss'z'"
check document