我從服務器獲取時間戳爲「2015-11-12T03:54:52Z」,它位於PST中。我想將此字符串轉換爲UTC /本地時區格式。我以下列方式試圖Objective-c:如何將PST轉換爲UTC /本地時區
NSDateFormatter *pstFormatter = [[NSDateFormatter alloc] init];
[pstFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"America/Los_Angeles"]];
[pstFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSDate *pstQUU = [pstFormatter dateFromString:@"2015-11-12T04:03:03Z"];
Original output : 2015-11-12 04:03:03 +0000
Expected output : 2015-11-12 12:03:03 +0000 (UTC)
爲什麼會產生Server Express的時間值服務器應該使用的Unix時間(UTC)? –
@DuncanC:服務器發送PST時間。 – Javeed
服務器正在發送時間字符串?讓服務器使用特定的時區是不好的設計。 UTC是通過互聯網交換時間/日期的標準。 –