我正在使用Twitter开发iOS应用程序,并且在以我想要的格式检索日期时遇到问题。当我逐步推出JSON时,我会发布每条推文和它们的发布日期,但是它处于不同的时区。我可以使用哪种转换器将采用ex:“time_zone”=“太平洋时间(美国和加拿大)”并将其转换为本地化时间。我已经把它转换为NSDate的日期字符串,所以我只是不知道如何应用时区更改。谢谢。
答案 0 :(得分:3)
您可以使用NSDateFormatter的timezone属性。
举一个例子,如果你想让日期在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";