Francois
Francois

Reputation: 10968

obj-c: how to parse a "human friendly" date?

I've read a many things about parsing date in obj-c, but I can't find anything dealing with dates like "Mon, 25 Apr 2011 11:53 am CDT"... I'd like to convert it to NSDate in a smart way but I'm running out of ideas.

Thanks.

Upvotes: 1

Views: 189

Answers (2)

Kal
Kal

Reputation: 24910

NSDateFormatter is a pretty complete class that covers all "human-friendly" date scenarios.

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html

There's also several questions on stackoverflow that seem very similar to your question, so a quick search should help you out.

Upvotes: 0

Dave DeLong
Dave DeLong

Reputation: 243146

-[NSDateFormatter dateFromString:]

You'd probably use @"EEE, d MMM yyyy hh:mm a zzz" as your date format string.

And by the way, googling "convert string to date objective-c" yields thousands of hits that have correct answers.

Upvotes: 4

Related Questions