Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Labeno

macrumors 6502
Original poster
Jul 21, 2008
351
1,089
Hey all,
Is there an iPhone API to determine if the iPhone is set to 12 or 24 time mode?
I want my apps to print time according to the iPhone system settings.
Thanks.
 
Hey all,
Is there an iPhone API to determine if the iPhone is set to 12 or 24 time mode?
I want my apps to print time according to the iPhone system settings.
Thanks.

You will want to use an NSDateFormatter, which respects the system date and time formats.
 
Determining 12 or 24 hour time

I need to determine 12 or 24 hour time for puproses other than printing time. NSDateFormatter cannot answer directly, so I need some other way. How can I deal with that task?
 
You can't, there's no API calls available to determine that. Make it a user preference in Settings.app if it's that important to your app.
 
Kind of ugly, but you could create a date of today at 1:00 PM and then get the string value from NSDateFormatter. If it's 13:00 then you know it's 24-hour. The value could then be cached so you only do it once.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.