How to convert NSString 2010-08-03 04:37:31.0 to August 3, 2010?
Is it possible?
How to convert NSString 2010-08-03 04:37:31.0 to August 3, 2010?
Is it possible?
Check out the NSDateFormatter documentation. You probably want a format string of @"%B %e, %Y"
for the output.
This is probably a duplicate but NSDateFormatter
is what you are looking for.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.S"];
NSDate *date = [dateFormatter dateFromString:inDateString];
[dateFormatter setDateFormat:@"MMMM dd',' yyyy"];
NSString *outDateString = [dateFormatter stringFromDate:date];
There are two problems with this approach though.
NSDateFormatterStyle
formats like NSDateFormatterLongStyle
.