简体   繁体   中英

rfc850 date format and NSDateFormatter

Im having a hard tim getting the NSDateFormatter to give me a correct date format. I need it to look like this:

Mon, 04 Jan 2010 10:10:00 GMT

But I am getting:

Mon, 04 Jan 2010 10:10:00 GMT+00:00

Using the format string:

EEE',' dd' 'MMM' 'yyyy HH':'mm':'ss z

No matter what value for timezone I use, the +00:00 appears to be stuck on the end. I realize I could just remove it form the resulting string, but that feels like cheating.

So how do I get the date formatter to not include a time offset value?

I had the same problem when generating Http Date in RC1123 format.

http://blog.mro.name/2009/08/nsdateformatter-http-header/

Has some good information, but basically just replaces z with the fixed string 'GMT'.

After much more research, I'm pretty sure this can't be done. So my simple string manipulation will have to do.

实际上http://blog.mro.name/2009/08/nsdateformatter-http-header/显示了正确的方法,因为RFC仅允许文字“ GMT”,并且NSDateFormatter被强制设置为GMT和英语工作日的时区和月份名称。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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