I am trying to get a string date into a date object so I can do some comparisons. My code is as follows:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy/MM/dd_hh:mm:ss"];
NSDate *date = [formatter dateFromString:@"2012/02/06_20:35:59"];
[formatter release];
NSLog(@"date = %@", date);
My NSLog is showing that *date = null;
Any help is appreciated. Thanks.
Does’t your format need to be
yyyy/MM/dd_HH:mm:ss?hhis 0-12 where asHHis 0-23.For reference, here is the doc where I got that nugget of information from – http://unicode.org/reports/tr35/tr35-10.html#Date_Format_Patterns