Objective-C 中的日期解析

发布于 2024-09-10 03:22:23 字数 239 浏览 2 评论 0原文

如何最有效地将其解析为 Objective-C NSDate?

“2010-07-13T11:22:33-07:00”

这是我尝试过

NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"yyyy-MMM-dd'T'HH:mm:ssZ"];

但没有成功

How can I parse this into an objective-c NSDate most efficiently?

"2010-07-13T11:22:33-07:00"

This is what I tried

NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"yyyy-MMM-dd'T'HH:mm:ssZ"];

but did not work

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

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

发布评论

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

评论(1

梦中楼上月下 2024-09-17 03:22:23

看看这里,我遇到了这个问题

“我的格式如果我将“+00:00”更改为“+0000”,那么我可以在格式中使用“Z”,如果我将其更改为“GMT+00:00”。 “然后我可以使用 ZZZZ 正确获取数据。似乎已经删除了一些东西来处理这种混合,因为它之前在 OS 3.x 上为我工作”

have a look here, i had that issue

"The format that I am being given is halfway between RFC 822 and GMT. if i change the "+00:00" to "+0000" then I can use the "Z" on my format. and if i change it to "GMT+00:00" then I can use ZZZZ to get the data properly. It seems that something has been stripped out to handle this hybrid as it was working for me before with OS 3.x"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文