objective c - NSDateformatter Converting date to string -
i having following date , time 2013-04-25 10:42:44 +0000. when convert above date string, getting output 2013-04-25 16:12:44. following code using convert date string
nsdateformatter *dateformatter = [[nsdateformatter alloc]init]; dateformatter.timezone = [nstimezone systemtimezone]; [dateformatter setdateformat:@"yyyy-mm-dd hh:mm:ss"]; nsstring *datestr= [dateformatter stringfromdate:date]]; nslog(@"datestr--%@",datestr);
this gets asked on , on (but difficult find via search).
when log nsdate
object, date in utc format. how description
method of nsdate
implemented.
as long difference seeing can accounted based on local timezone relative utc, seeing correct , expected behavior.
btw - there no reason set date formatter's timezone "system" timezone. done default. same locale. set timezone or locale if want different current values.
Comments
Post a Comment