Converter NSString to NSDate
1 2 3 4 5 6 7 8 |
NSString *dateString = @"01-02-2010"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; // this is imporant - we set our input date format to match our input string // if format doesn't match you'll get nil from your string, so be careful [dateFormatter setDateFormat:@"dd-MM-yyyy"]; NSDate *dateFromString = [[NSDate alloc] init]; // voila! dateFromString = [dateFormatter dateFromString:dateString]; |