I have a problem with date formatting in iOS 9, it works fine with iOS 8, and also works when I test it in a simulator with iOS 9, but when the test on a real device with iOS 9, I get null. Below is the code I'm using
NSLog(@"String Date: '%@'", stringDate);
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM/dd/yyyy hh:mm:ss a"];
NSDate *date = [dateFormat dateFromString:stringDate];
NSLog(@"Date: %@", date);
In the log I get:
String Date: '8/29/2015 4:13:39 PM'
Date: (null)
Also, if I use uppercase h (H or HH), I always get that hour is 10.
source
share