this question has answer here:
- nsdateformatter difference 2 answers
this code :
let datestring = "2015-07-13t17:32:32.781z" let dateformatter = nsdateformatter() dateformatter.dateformat = "yyyy-mm-dd't'hh:mm:ss.sss'z'" var thedate = dateformatter.datefromstring(datestring)! println(thedate) // 2015-07-13 16:32:32 +0000 one hour substracted original date during process. why ?
@mipadi has explained problem, think should set time zone utc.
let datestring = "2015-07-13t17:32:32.781z" let dateformatter = nsdateformatter() dateformatter.dateformat = "yyyy-mm-dd't'hh:mm:ss.sss'z'" dateformatter.timezone = nstimezone(abbreviation: "utc") var thedate = dateformatter.datefromstring(datestring)! println(thedate)
Comments
Post a Comment