-2
簡單的一個正在擾亂我,無法解決。我希望將當前的UTC轉換爲一串數字,但時間不對?當它的00小時它顯示爲10 ..空間在那裏只是爲了更容易閱讀。NSDate到NSString有時間錯誤?
登錄:
2014-09-01 10:24:16.337 MyApp[44834:60b] 2014-09-01 00:24:16 +0000
2014-09-01 10:24:16.339 MyApp[44834:60b] 20140901 102416
代碼:
NSDate *currentDate = [[NSDate alloc] init];
NSLog(@"%@", currentDate);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyyMMdd HHmmss"];
NSString *currentDateString = [dateFormatter stringFromDate:currentDate];
NSLog(@"%@", currentDateString);
不,這不是錯誤 2014-09-01 00:24:16 +0000是GMT + 0當前時間+ 0 是您當前的時區+10? http://stackoverflow.com/questions/6229024/nsdate-format-outputting-wrong-date – 2014-09-01 00:36:44