I have this method that converts date to string:
- (NSString*)getDateTimeBasedOnDeviceTimeFormat:(NSDate *)theDate{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
NSDate *dateSource;
NSString *dateStr;
[dateFormatter setLocale:[NSLocale currentLocale]];
if (theDate) {
dateSource = theDate;
} else {
dateSource = [NSDate date];
}
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]]; //tried local timezone
[dateFormatter setDateStyle:NSDateFormatterLongStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
dateStr = [dateFormatter stringFromDate:dateSource];
return dateStr;
}
For iOS 10.3.1:
the returned value is October 31, 2017 at 2:26 PM (this is wrong)
For iOS 11:
the returned value is October 31, 2017 at 10:26 AM (this is correct)
Both the simulators have the same language and region set. English (US).
mac date time settings:
I have no idea why this conversion shows up wrong in iOS 10.3.1
Can someone point me in a right direction ?