How to convert NSDate to a string like this:
Monday, November 22, 2010
.. and then back to NSDate?
Use NSDateFormatter
Something like:
NSDate *date=//...; ; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setTimeStyle:NSDateFormatterNoStyle]; [dateFormatter setDateStyle:NSDateFormatterLongStyle]; NSString *string=[dateFormatter stringFromDate:date]; //.... NSDate *newDate=[dateFormatter dateFromString:string];
There are more detailed information that I don’t consider, such as problems with Locale and much more, but this should make you go
You need to use the NSDateFormatter class, especially stringFromDate and dateFromString . Links have good examples.
stringFromDate
dateFromString