Wondering about the best way to turn a string like “yyyymmdd” into a string with the format “mm-dd-yyyy”. Tried NSDateFormatter with no luck. Any help is appreciated!
My solution is as follows:
NSString *dateString = @"22082011;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyyMMdd"];
NSDate *date = [dateFormatter dateFromString:dateString];
[dateFormatter setDateFormat:@"MMM d, YYYY"];
dateString = [dateFormatter stringFromDate:date];
[dateFormatter release];
You will first need to parse it:
and then you can use this: