0

因此,我在 UITableView 中使用日期数组作为部分标题。我的数据在数组中的日期如下

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

但是当我运行该应用程序时,部分标题全部移回了一天,因此它们如下:

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

是什么赋予了?我从服务器中提取的数据特定于 timeZone。我们知道何时使用我们的应用程序以及在哪一天使用(想想旅行马戏团)。

我确信这与 NSTimeZone 有关,所以我尝试了以下方法,但没有成功。

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

有谁知道有解决办法吗?

4

1 回答 1

0

将日期设置为 UTC 并解决了问题。

于 2012-08-20T16:00:48.670 回答