Hi at all I want to parsing a date from XML with this format:
2012/05/25 02:37
- (void) compareDate:(NSString *)dataUno secondaData:(NSString *) dataDue {
NSDateFormatter *dateFormat= [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm"];
NSDate *dt1 = [dateFormat dateFromString:dataUno];
NSDate *dt2 = [dateFormat dateFromString:dataDue];
NSLog(@"dt1: %@ dt2: %@", dt2, dt1);
}
but when I try to print the date I get a null value, where is the error?
kikko088
Your date formatter’s format string
"yyyy-MM-dd HH:mm"doesn’t match your date format. Actually,"2012/37/29 02:37"isn’t a date under any format, but I assume the 37 is a typo and that’s supposed to be the month.Try this: