can anyone please tell me why this code snippet returns nil in my log file:
NSString *dateString = [[NSString alloc] initWithString: @"2011-08-23 15:00"];
NSLocale *englishLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-mm-dd HH:MM"];
[dateFormatter setLocale:englishLocale];
NSLog(@"%@",[dateFormatter dateFromString:dateString]);
Thanks a lot.
Check my variant:
As you see I’ve changed date format to :
@"yyyy-MM-dd HH:mm"All formats can be found here: UNICODE LOCALE DATA MARKUP LANGUAGE (LDML)