我从服务器获取时间戳为“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是通过互联网交换时间/日期的标准。 –