double seconds = -62167464057.000;
NSDate *oldDate = [NSDate dateWithTimeIntervalSince1970:seconds];
MELog("oldDate = %@", oldDate);//oldDate = 0002-12-29 03:59:03 +0000
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *formattedDateString = [dateFormatter stringFromDate:oldDate];
NSLog(@"formattedDateString = %@", formattedDateString);//formattedDateString = 3:57 AM
在上面的代碼,日期部件有足夠的時間3:59,但是,當我們格式化提取時間字段,我們得到了3:57NSDateFormatter將不適用於1970年以前的日期嗎?
我的時區是倫敦,所以它應該返回3:59
這是因爲我們試圖格式化1970年以前的日期嗎?請確認是否有人知道。