简体   繁体   English

在Objective-C中解析日期

[英]Parsing date in Objective-C

How can I parse this into an objective-c NSDate most efficiently? 如何最有效地将其解析为objective-c NSDate?

"2010-07-13T11:22:33-07:00" “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 但没有奏效

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" “我给出的格式是在RFC 822和GMT之间。如果我将”+00:00“更改为”+0000“,那么我可以在我的格式上使用”Z“。如果我将其更改为” GMT + 00:00“然后我可以使用ZZZZ来正确获取数据。似乎有些东西已被剥离以处理这种混合,因为它之前用于OS 3.x”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM