可能重複:
NSDate/NSDateFormatter returning GMT on iPhone iOS 4.3爲什麼NSString的日期值被NSDateFormatter轉換爲GMT?
當執行
NSString *[email protected]"2012-10-19 19:37:54";
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *test=[formatter dateFromString:inputDateString];
下面的代碼 「測試」 的值是23時37分54秒二〇一二年十月十九日+0000而不是等於inputDateString的日期值。爲什麼要將日期轉換爲GMT?
編輯:如何獲取輸入字符串日期並將其轉換爲等效的NSDate對象?
這有很多重複... – jrturton
http://stackoverflow.com/search?q=NSDate+GMT – jrturton