全
我是ios编程的新手。我想在方法中设置CST
[dateFormatter setTimeZone:]我已经创建了一个示例项目来获取所有已知的时区代码,如下所示:
NSArray *timeZoneNames = [NSTimeZone knownTimeZoneNames];
for (NSTimeZone *timezon in timeZoneNames) {
NSLog(@"%@",timezon);
}它提供了以下结果:
会议开始于2011-09-28 09:50:28 +0530。2011-09-28 09:50:29.535非洲/阿比让
2011-09-28 09:50:29.537非洲/阿克拉
2011-09-28 09:50:29.537时区测试10352:207非洲/埃塞俄比亚
2011-09-28 09:50:29.538非洲/阿尔及利亚时区
..
..
..
..
2011-09-28 09:50:29.765时区测试10352:207太平洋/帕果_帕果
2011-09-28 09:50:29.766太平洋/帕劳
2011年09月28日09:50:29.766太平洋时区/皮特凯恩
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太平洋时区/塔拉瓦
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太平洋时区/清晨
2011年9月28日09:50:29.778太平洋/瓦利斯时区10352:207
任何人都可以在上面的列表中说出CST(中央标准时区)的名称,提前谢谢
发布于 2011-09-28 13:29:50
try this by first method u got all time zone after that wat u want u set by key value.
NSLog(@"%@",[NSTimeZone abbreviationDictionary]);
[dateFormater setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"CST"]];发布于 2011-09-28 13:13:38
只需使用以下代码,
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"CST"]];发布于 2011-09-28 13:15:21
试试这个:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss";
NSTimeZone *cst = [NSTimeZone timeZoneWithAbbreviation:@"GMT-06:00"];
[dateFormatter setTimeZone:cst];https://stackoverflow.com/questions/7578404
复制相似问题