How would I convert an NSDate into a string like this:
Monday, November 22, 2010
.. and then back again into an 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 details I'm not covering, such as the Locale issues and whatnot, but this should get you going
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With