我正在使用 twitter 开发 iOS 应用程序,在以我想要的格式检索日期时遇到问题。当我对 JSON 进行分阶段时,我会发布每条推文和它们的发布日期,但是它位于不同的时区。我可以使用什么转换器来获取 ex: "time_zone" = "Pacific Time (US & Canada)" 并将时间转换为本地化时间。我已经将日期字符串转换为 NSDate,所以我只是不知道如何应用时区更改。谢谢你。
问问题
920 次
1 回答
3
您可以使用 NSDateFormatter 的时区属性。
举个例子,如果您希望日期在 EST 中,您可以使用:
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@\"EST\"]];
这是使用 NSTimeZone 支持的缩写的完整列表。
ADT = "America/Halifax";
AKDT = "America/Juneau";
AKST = "America/Juneau";
ART = "America/Argentina/Buenos_Aires";
AST = "America/Halifax";
BDT = "Asia/Dhaka";
BRST = "America/Sao_Paulo";
BRT = "America/Sao_Paulo";
BST = "Europe/London";
CAT = "Africa/Harare";
CDT = "America/Chicago";
CEST = "Europe/Paris";
CET = "Europe/Paris";
CLST = "America/Santiago";
CLT = "America/Santiago";
COT = "America/Bogota";
CST = "America/Chicago";
EAT = "Africa/Addis_Ababa";
EDT = "America/New_York";
EEST = "Europe/Istanbul";
EET = "Europe/Istanbul";
EST = "America/New_York";
GMT = GMT;
GST = "Asia/Dubai";
HKT = "Asia/Hong_Kong";
HST = "Pacific/Honolulu";
ICT = "Asia/Bangkok";
IRST = "Asia/Tehran";
IST = "Asia/Calcutta";
JST = "Asia/Tokyo";
KST = "Asia/Seoul";
MDT = "America/Denver";
MSD = "Europe/Moscow";
MSK = "Europe/Moscow";
MST = "America/Denver";
NZDT = "Pacific/Auckland";
NZST = "Pacific/Auckland";
PDT = "America/Los_Angeles";
PET = "America/Lima";
PHT = "Asia/Manila";
PKT = "Asia/Karachi";
PST = "America/Los_Angeles";
SGT = "Asia/Singapore";
UTC = UTC;
WAT = "Africa/Lagos";
WEST = "Europe/Lisbon";
WET = "Europe/Lisbon";
WIT = "Asia/Jakarta";
于 2013-03-27T21:14:09.753 回答