this has been driving me crazy, someone please show me where i screwed it up.
I have created a new project to test this as well. Environment is xcode 3.2.5 running in the simulator and on a device has same result.
When i create a date formatter, and set its format then pass in a string, something is not working on the date formatter.
int tmpMonth = 11;
int tmpYear = 2010;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"m/d/yyyy"];
NSString *dateAsString = [[NSString alloc] initWithFormat:@"%d/23/%d",tmpMonth,tmpYear];
NSDate *theDate = [[NSDate alloc] initWithTimeInterval:0 sinceDate:[dateFormatter dateFromString:dateAsString]];
[dateFormatter setDateFormat:@"MMMM d, yyyy"];
NSLog(@"%@",[dateFormatter stringFromDate:theDate]);
[dateFormatter setDateFormat:@"m/d/yyyy"];
NSLog(@"%@",[dateFormatter stringFromDate:theDate]);
[dateFormatter release];
[theDate release];
[dateAsString release];
this results in this output:
[Session started at 2010-12-03 17:47:04 -0600.]
2010-12-03 17:47:05.274 wtfDateFormatter[18970:207] January 23, 2010
2010-12-03 17:47:05.277 wtfDateFormatter[18970:207] 11/23/2010
I am not sure why it is printing January when I give it the format MMMM, as this is working just fine in other parts of my app, it just uses a different NSDate source.