nsdate - swift stored date turns different when formatted to string -


this question has answer here:

i stored date in core data (as date), , println shows correctly value: april 21 (is var datex below), when right after println format string following code, label linked shows april 22 (which today, wonder tomorrow show 23 etc.), problem? anyone? thank you

if datex != nil{             var dateformatter = nsdateformatter()             dateformatter.dateformat = "mmm dd, yyyy"             dateformatter.timezone = nstimezone.defaulttimezone()             var datexstring = dateformatter.stringfromdate(datex nsdate)            startlabel.text = "profile created on \(datexstring)"         } 

println datex , datexstring:

enter image description here

my time zone rome (italy)

you have timezone issue. located? defaulttimezone gmt/zulu time -5 hrs east coast.

a way check use timeintervalsince1970 function (i think thats called). if stored date , retrieved date have same value same date , have display problem.

timeintervalsince1970 returns nstimeinterval double


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -