ios - NSLog showing the previous Date -


i want retrieve entries core data added between 2 dates.i using nspredicate. not getting correct result tried logging date.it showing previous dates.after googling while added

[dateformatter settimezone:[nstimezone timezoneforsecondsfromgmt:0]]; code.now,its showing correct dates results still wrong.

this code used.

nsdate *fromdate = [[self dateformatter]datefromstring:self.fromdatefield.text]; nslog(@"%@",fromdate); nsdate *todate = [[self dateformatter]datefromstring:self.todatefield.text]; nslog(@"%@",todate); nscomparisonresult result = [fromdate compare:todate]; switch (result) {     case nsorderedascending:     {         //code     }  - (nsdateformatter *)dateformatter { static nsdateformatter *dateformatter = nil; if (dateformatter == nil)  {     dateformatter = [[nsdateformatter alloc] init];     [dateformatter setdatestyle:nsdateformattermediumstyle];     [dateformatter settimestyle:nsdateformatternostyle];     [dateformatter settimezone:[nstimezone timezoneforsecondsfromgmt:0]]; }    return dateformatter; } 

thanks in advance

if log nsdate object directly display tome in gmt/utc timezone. have log output of date formatter.

nslog(@"%@",[self.dateformatter stringfromdate:todate]); 

this take timezone in account. or better: timezone of dateformatter's calendar — device default if dont change that.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -