Iphone NSTimezone如何将CST设置为NSDateFormatter

Iphone NSTimezone如何将CST设置为NSDateFormatter,iphone,nsdateformatter,nstimezone,Iphone,Nsdateformatter,Nstimezone,全部 我对ios编程还不熟悉。 我想在方法中设置CST [dateFormatter setTimeZone:] 我创建了一个示例项目来获取所有已知时区 代码如下: NSArray *timeZoneNames = [NSTimeZone knownTimeZoneNames]; for (NSTimeZone *timezon in timeZoneNames) { NSLog(@"%@",timezon); } 它给出了以下结果: [会议于2011-09-2809:50:28

全部

我对ios编程还不熟悉。 我想在方法中设置CST

[dateFormatter setTimeZone:]
我创建了一个示例项目来获取所有已知时区 代码如下:

NSArray *timeZoneNames = [NSTimeZone knownTimeZoneNames];

for (NSTimeZone *timezon in timeZoneNames) {

    NSLog(@"%@",timezon);
}
它给出了以下结果:

[会议于2011-09-2809:50:28+0530开始。] 2011-09-28 09:50:29.535时区测试[10352:207]非洲/阿比让

2011-09-28 09:50:29.537时区测试[10352:207]非洲/阿克拉

2011-09-28 09:50:29.537时区测试[10352:207]非洲/亚的斯亚贝巴

2011-09-28 09:50:29.538时区测试[10352:207]非洲/阿尔及尔

2011-09-28 09:50:29.765时区测试[10352:207]太平洋/帕果帕果

2011-09-28 09:50:29.766时区测试[10352:207]太平洋/帕劳

2011-09-28 09:50:29.766时区测试[10352:207]太平洋/皮特凯恩

2011-09-28 09:50:29.767时区测试[10352:207]太平洋/波恩佩

2011-09-28 09:50:29.768时区测试[10352:207]太平洋/波纳佩

2011-09-28 09:50:29.769时区测试[10352:207]太平洋/莫尔斯比港

2011-09-28 09:50:29.773时区测试[10352:207]太平洋/拉罗通加

2011-09-28 09:50:29.775时区测试[10352:207]太平洋/塞班岛

2011-09-28 09:50:29.775时区测试[10352:207]太平洋/大溪地

2011-09-28 09:50:29.776时区测试[10352:207]太平洋/塔拉瓦

2011-09-28 09:50:29.776时区测试[10352:207]太平洋/汤加塔普

2011-09-28 09:50:29.777时区测试[10352:207]太平洋/楚克

2011-09-28 09:50:29.778时区测试[10352:207]太平洋/威克

2011-09-28 09:50:29.778时区测试[10352:207]太平洋/沃利斯

任何人都可以说出上面列表中CST(中央标准时区)的名称
提前感谢

只需使用以下代码

[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"CST"]];

只需使用以下代码

[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"CST"]];
试试这个:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss";
NSTimeZone *cst = [NSTimeZone timeZoneWithAbbreviation:@"GMT-06:00"];
[dateFormatter setTimeZone:cst];
试试这个:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss";
NSTimeZone *cst = [NSTimeZone timeZoneWithAbbreviation:@"GMT-06:00"];
[dateFormatter setTimeZone:cst];