Question

So I am using an array of dates as Section Headers in my UITableView. The dates of my data in the arrays is as follows

07/12/2012
07/13/2012
07/14/2012

But when I run the app the section headers are all moved back one day so they are as follows:

07/11/2012
07/12/2012
07/13/2012

What gives? The data I am pulling from the server is specific to timeZone. We know when our app will be used and on what day (think traveling circus).

I am sure this has to do with NSTimeZone, so I tried the following, which did not work.

self.sectionDateFormatter = [[NSDateFormatter alloc] init];
[self.sectionDateFormatter setDateStyle:NSDateFormatterLongStyle];
[self.sectionDateFormatter setTimeStyle:NSDateFormatterNoStyle];
[self.sectionDateFormatter setTimeZone:[NSTimeZone localTimeZone]];

Anyone know have a solution?

Was it helpful?

Solution

Set the dates to UTC and it fixed the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top