views:

642

answers:

2

I have a date string (well, NSData, but that's easy to convert to a string) that's in what I believe is the format the HTTP standard uses:

Mon Apr 17 19:34:46 UTC 2006

Is there any better (i.e. less error-prone) way to parse that than specifying the format string by hand in an NSDateFormatter?

(My application is an iPhone app, but I suspect standard Cocoa solutions will work too, since NSDate and NSDateFormatter are part of Foundation.)

+1  A: 

No, I don't think there is a better way.

If you have some outside input, you must know the format of your input beforehand, and you can only prepare for problems, i.e. a fail over parser with an alternate NSDateFormatter.

Alexandre L Telles
I thought that might be the case. Thanks anyway.
Brent Royal-Gordon
+1  A: 

Actually the standard HTP date format is:

"Mon, 11 May 2009 02:49:52 GMT"