NSTimezone 如何将 CST 设置为 nsdateformater

发布于 2024-12-06 18:11:53 字数 1659 浏览 8 评论 0原文

我对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 Timezonetest[10352:207] 非洲/阿比让

2011-09-28 09:50:29.537 Timezonetest[10352:207] 非洲/阿克拉

2011-09-28 09:50:29.537 Timezonetest[10352:207] 非洲/Addis_Ababa

2011-09-28 09:50:29.538 Timezonetest[10352:207] 非洲/阿尔及尔

...................... ……………………………………

........................

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

2011-09-28 09:50:29.766 Timezonetest[10352:207] 太平洋/帕劳

2011-09-28 09:50:29.766 Timezonetest[10352:207] 太平洋/皮特凯恩

2011-09-28 09:50: 29.767 Timezonetest[10352:207] 太平洋/波纳佩

2011-09-28 09:50:29.768 Timezonetest[10352:207] 太平洋/波纳佩

2011-09-28 09:50:29.769 Timezonetest[10352:207] 太平洋/Port_Moresby

2011-09-28 09:50:29.773 Timezonetest[10352:207] 太平洋/拉罗汤加

2011-09-28 09:50:29.775 Timezonetest[10352:207] 太平洋/塞班岛

2011-09-28 09:50:29.775 Timezonetest[10352:207] 太平洋/

塔希提岛 2011-09-28 09:50:29.776 Timezonetest[10352:207] 太平洋/塔拉瓦 2011-09-28 09:50:29.776

Timezonetest[10352:207] 太平洋/汤加塔布

2011-09 -28 09:50:29.777 Timezonetest[10352:207] 太平洋/特鲁克

2011-09-28 09:50:29.778 Timezonetest[10352:207] 太平洋/唤醒

2011-09-28 09:50:29.778 Timezonetest[10352:207] 太平洋/沃利斯

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

all

I'm new to ios programming.
I want to set CST in the method

[dateFormatter setTimeZone:]

I have created a sample project to get all known timezones
Code is here:

NSArray *timeZoneNames = [NSTimeZone knownTimeZoneNames];

for (NSTimeZone *timezon in timeZoneNames) {

    NSLog(@"%@",timezon);
}

It gives the following result:

[Session started at 2011-09-28 09:50:28 +0530.]
2011-09-28 09:50:29.535 Timezonetest[10352:207] Africa/Abidjan

2011-09-28 09:50:29.537 Timezonetest[10352:207] Africa/Accra

2011-09-28 09:50:29.537 Timezonetest[10352:207] Africa/Addis_Ababa

2011-09-28 09:50:29.538 Timezonetest[10352:207] Africa/Algiers

........................

........................

........................

........................

2011-09-28 09:50:29.765 Timezonetest[10352:207] Pacific/Pago_Pago

2011-09-28 09:50:29.766 Timezonetest[10352:207] Pacific/Palau

2011-09-28 09:50:29.766 Timezonetest[10352:207] Pacific/Pitcairn

2011-09-28 09:50:29.767 Timezonetest[10352:207] Pacific/Pohnpei

2011-09-28 09:50:29.768 Timezonetest[10352:207] Pacific/Ponape

2011-09-28 09:50:29.769 Timezonetest[10352:207] Pacific/Port_Moresby

2011-09-28 09:50:29.773 Timezonetest[10352:207] Pacific/Rarotonga

2011-09-28 09:50:29.775 Timezonetest[10352:207] Pacific/Saipan

2011-09-28 09:50:29.775 Timezonetest[10352:207] Pacific/Tahiti

2011-09-28 09:50:29.776 Timezonetest[10352:207] Pacific/Tarawa

2011-09-28 09:50:29.776 Timezonetest[10352:207] Pacific/Tongatapu

2011-09-28 09:50:29.777 Timezonetest[10352:207] Pacific/Truk

2011-09-28 09:50:29.778 Timezonetest[10352:207] Pacific/Wake

2011-09-28 09:50:29.778 Timezonetest[10352:207] Pacific/Wallis

Anyone can say which is the name for CST(central Standard timezone) in the above list
Thanks in Advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

佞臣 2024-12-13 18:11:53
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"]];
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"]];
ぶ宁プ宁ぶ 2024-12-13 18:11:53

只需使用以下代码,

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

Just use the following code,

[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"CST"]];
樱花落人离去 2024-12-13 18:11:53

试试这个:

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

Try this:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss";
NSTimeZone *cst = [NSTimeZone timeZoneWithAbbreviation:@"GMT-06:00"];
[dateFormatter setTimeZone:cst];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文