Reputation: 14835
Here is my code:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy"];
if ([dateFormatter dateFromString:@"11/09/2010"])
{
//PASS
}
else
{
//FAIL
}
Why is it going into the FAIL section every time?
Upvotes: 0
Views: 74
Reputation: 9149
Try setting the date format like this:
[dateFormatter setDateFormat:@"dd/MM/yyyy"];
Or the other way around, depending on which field is days and which is months.
Upvotes: 1