I want to covert from a NSString to NSDate object.
My string is : @"01/01/2013.
Here is the code to convert the string to NSDate:
- (NSDate*) formatDateTimeFromString: (NSString* ) string{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
NSDate* date= [dateFormatter dateFromString:string ];
return date;
}
I debug into the function and see that the date object is always nil. Did I have any mistake?
Your date formatter is wrong (might be hard to see at first)
Change
to