Reputation: 1484
How can i get information about which hours format prefer user?
Is it any [application instace].prefferedTimeFormat
or something like this?
Upvotes: 1
Views: 566
Reputation: 10201
It's more like a hack can you try with this. If you use NSDateFormatterMediumSytle
if user has turned on 24 hour format the dateFormat would be H:mm:ss
if it's not turned on the format would be h:mm:ss a
.
If you just want to set the format based on the user preferences just set the style of date and time to formatter. It will take care of the rest.
- (BOOL)is24HourFormat
{
NSDateFormatter *dateFormatter = [NSDateFormatter new];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
return [dateFormatter.dateFormat isEqualToString:@"H:mm:ss"];
}
Upvotes: 5