Determining 12 or 24 hour time

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

  1. Labeno macrumors regular

    Labeno

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

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

    Joined:
    Dec 24, 2008
    #3
    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

    Joined:
    Sep 17, 2003
    #4
    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.
     
  5. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #5
    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