I am using the following code for get system time format in ios. And it work fine when my current region set with "United State" but when I change the region from "United State" to "United Kingdom" it always give 12 hour formate.
#pragma mark
#pragma mark - get system time
-(BOOL)getSystemTimeFormat
{
NSString *strDateFormate = @"hh a";
NSString *dateFormat = [NSDateFormatter dateFormatFromTemplate:strDateFormate options:0 locale:[NSLocale currentLocale]];
if ([dateFormat rangeOfString:@"h"].location != NSNotFound)
{
[kNSUserDefaults setBool:YES forKey:@"TimeFormat"];
[kNSUserDefaults synchronize];
return YES;
}
else
{
[kNSUserDefaults setBool:NO forKey:@"TimeFormat"];
[kNSUserDefaults synchronize];
return NO;
}
}
Log of the "United State" region::
2015-01-27 11:32:16.090 [350:60b] 12 Formate :: 0
2015-01-27 11:32:16.585 [350:60b] Connect
2015-01-27 11:32:16.591 [350:60b] Loction update...
2015-01-27 11:32:16.604 [350:60b] Loction update...
2015-01-27 11:32:16.622 [350:60b] Loction update...
Log of the "United Kingdom" region::
2015-01-27 11:33:35.785 [364:60b] 12 Formate :: 1
2015-01-27 11:33:36.777 [364:60b] Connect
2015-01-27 11:33:36.780 [364:60b] Loction update...
2015-01-27 11:33:36.806 [364:60b] Loction update...
2015-01-27 11:33:36.832 [364:60b] Loction update...