Determining 12 or 24 hour time

Discussion in 'iOS Programming' started by Labeno, Sep 20, 2008.

  1. Labeno macrumors 6502


    Jul 21, 2008
    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.
  2. admanimal macrumors 68040

    Apr 22, 2005
    You will want to use an NSDateFormatter, which respects the system date and time formats.
  3. 123321 macrumors newbie

    Dec 24, 2008
    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?
  4. Pring macrumors 6502

    Sep 17, 2003
    You can't, there's no API calls available to determine that. Make it a user preference in if it's that important to your app.
  5. kainjow Moderator emeritus


    Jun 15, 2000
    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.

Share This Page