I have a string as follows:
2012-11-01
And I want to get a string representing the day from that. So this is how I approach it:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"yyyy-mm-dd"];
NSDate *date = [dateFormatter dateFromString: @"2012-11-01"];
[dateFormatter setDateFormat: @"EEE"];
NSString *string = [dateFormatter stringFromDate: date];
NSLog(@"%@", string);
And the output is:
Sun
When it really should be:
Thu
(If my calculations are correct!)
So what is the problem here? Is this an internal bug? Something wrong with my code?
Thanks!
Change your first date format string to:
It should work then.