Skip to content

Instantly share code, notes, and snippets.

@mwaterfall
Created May 3, 2011 16:16
Show Gist options
  • Save mwaterfall/953647 to your computer and use it in GitHub Desktop.
Save mwaterfall/953647 to your computer and use it in GitHub Desktop.
Determine whether iPhone is displaying 12 or 24 hour time
@implementation NSLocale (Misc)
- (BOOL)timeIs24HourFormat {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:self];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateString = [formatter stringFromDate:[NSDate date]];
NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
BOOL is24Hour = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
[formatter release];
return is24Hour;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment