4

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?

2 Answers 2

8

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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

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

1 Comment

FINALLY i've been searching for this for 15 minutes :) Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.