views:

293

answers:

2

How can i format a string like "Fri Oct 17 00:00:00 +0200 2003" to a simple date string like Fri Oct 17 2003?

Is there any easy solution?

+5  A: 

Yes, use the NSDateFormatter to parse the first into an NSDate and then use another NSDateFormatter to write out that NSDate in the second format.

St3fan
Or the same `NSDateFormatter` with it's `dateFormat` changed.
Dave DeLong
But how to handle "+0200"? Something like this?[dateFormat setDateFormat:@"EEE MMM d hh:mm:ss +0200 YYYY"];
phx
Ok, this works for me:[dateFormat setDateFormat:@"EEE MMM d hh:mm:ss ZZZ YYYY"];Thank you!
phx
+1  A: 

You can find a list of the date format specifiers here: Unicode Date Formats

nall