NSDateFormatter生成错误的日期

时间:2013-01-04 10:46:50

标签: ios nsdateformatter

我正在使用NSDateFormatter将字符串转换为NSDate

1 NSDateFormatter *df = [[NSDateFormatter alloc]init];
2 [df setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
3 [df setDateFormat:@"YYYY-MM-dd"];
4 NSDate *dueDate = [df dateFromString:@"1970-01-01"];

当我检查dueDate时,错误一年:

po dueDate
(NSDate *) $0 = 0x1cdc08d0 1971-01-01 00:00:00 +0000

我这样做是错误的还是可能与“请勿打扰”功能中的错误相同?

http://www.forbes.com/sites/adriankingsleyhughes/2013/01/03/apples-ios-6-do-not-disturb-bug-means-your-iphone-wont-disturbed-you-until-next-week/

0 个答案:

没有答案