NSDate differs with different timezones in iOS -


i have calendar app, in highlight current date,

i have followed following steps, @ present device time 11:59 am,

indian time zone, change first 9.am, change time zone san jose ,

i time 25th june 9.34 pm, in device calendar shows 25th june,

in app still shows 26th june.

i getting current date way

-(void)initialize {     nscalendar *gregorian = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar];     [gregorian settimezone:[nstimezone timezonewithabbreviation:@"utc"]];     nsdatecomponents *weekdaycomponents = [gregorian components:(nsdaycalendarunit | nsyearcalendarunit | nsmonthcalendarunit  | nsminutecalendarunit)fromdate:[nsdate date]];     nsinteger day    = [weekdaycomponents day];     nsinteger month  = [weekdaycomponents month];      nsinteger year   = [weekdaycomponents year];     [m_dateformatter settimezone:[nstimezone timezonewithabbreviation:@"utc"]];      m_dateformatter.dateformat = @"dd/mm/yyyy";      nsdatecomponents *timezonecomps=[[nsdatecomponents alloc] init];     [timezonecomps setday:day];     [timezonecomps setmonth:month];     [timezonecomps setyear:year];     [timezonecomps sethour:00];     [timezonecomps setminute:00];     [timezonecomps setsecond:01];      m_currentdate         = [gregorian datefromcomponents:timezonecomps];     } 

so, need in regard.

i think [nstimezone systemtimezone] give current timezone detected (or set) device. since timezone cached in app can call [nstimezone resetsystemtimezone] make sure info date. so, in code:

[nstimezone resetsystemtimezone]; [m_dateformatter settimezone:[nstimezone systemtimezone]];


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -