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:57
我的时区是伦敦,所以它应该返回 3:59
这是因为我们试图格式化 1970 年之前的日期吗?请确认是否有人知道。