I am attempting convert this string “2012-02-05T00:00:00+00:00” into a more attractive, nicely formatted string like “Tuesday March 5, 2012.
I have an example that I’m working from:
NSString *dateStr = @"20081122";
// Convert string to date object
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyyMMdd"];
NSDate *date = [dateFormat dateFromString:dateStr];
// Convert date object to desired output format
[dateFormat setDateFormat:@"EEEE MMMM d, YYYY"];
dateStr = [dateFormat stringFromDate:date];
NSLog(@"date: %@", dateStr);
[dateFormat release];
How would I accommodate for the date format “2012-02-05T00:00:00+00:00” using similar code above?
Thank you.
When i see your time “2012-02-05T00:00:00+00:00”, I think you are printing a “NSDate” into your console. In that time “2012-02-05” is a date and “T00:00:00+00:00” is a time. So when you need to use date like this,
you have to format like this
If you want to convert the date component into as you liked try this
You can even do like this to convert the current date into as you like.