NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
NSTimeZone *gmt = [NSTimeZone systemTimeZone];
[dateFormatter setTimeZone:gmt];
NSString* fileTime = [infoArray objectAtIndex:5];
NSDate* sessionStartDate = [dateFormatter dateFromString:fileTime];
NSLog(@"%@", [infoArray objectAtIndex:5]);
NSLog(@"%@", sessionStartDate);
两个 NSLog:
2013-07-17 01:28:50
2013-07-17 05:28:50 +0000
两个应该是一样的,但不是。小时显示不同。我确实尝试过'hh'而不是大写,但同样的问题。