Sunday, 15 July 2012

ios - Getting one date less -



ios - Getting one date less -

this question has reply here:

nsdate format outputting wrong date 5 answers

i don't why i'm getting 1 date less, when i'm converting string date, i'm getting 1 date less, e.g. when i'm converting 18/06/2014, i'm getting 2014-06-17, thought why problem, codes are:

nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"dd/mm/yyyy"]; nsdate *date = [dateformatter datefromstring:@"18/06/2014"];

this i'm getting wholly log: 2014-06-17 20:00:00 +0000

you have take timezone account. current timezone seems ahead of gmt. if print entire date time stamp, difference. suggest add together timezone nsdateformatter

nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"dd/mm/yyyy"]; dateformatter.timezone = [nstimezone timezoneforsecondsfromgmt:0]; nsdate *date = [dateformatter datefromstring:@"18/06/2014"]; nslog(@"date : %@", date);

ios date

No comments:

Post a Comment