I have a String which has the following format: 2011-08-19T00:00:00 and I want now to change it in the following date format: August 19, 2011
I used the NSDateFormater this way:
NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"MMMM dd, yyyy"];
NSDate *date = [formatter dateFromString:shiftNote.startDate];
But without success, date is always null.
Wheres the failure?
BR
When you use
[formatter setDateFormat:@"%B %d, %Y"];, that means you must have a date already in this format. Since “2011-08-19T00:00:00” is not in this format, you’ll have to convert it to a date first, then back to a string.