3

I have a 24h formatted time string like 13:30 which I must translate into a 12h time format string when the user's locale uses AM/PM. How can I detect that reliably?

openfrog
  • 40,201
  • 65
  • 225
  • 373
  • 2
    It's not just the locale. Regardless of locale, the user can choose to use 24-hour time (or not) in the Settings app under General, Date & Time. – rmaddy Jan 21 '13 at 21:35
  • Have you tried [NSLocale currentLocale] or [NSLocale systemLocale] ? – tttthomasssss Jan 21 '13 at 21:36
  • @rmaddy is correct. You can get bit if the locale is one way and the Settings value is the other way, and I'm not sure there's a good way to test for this other than to format something and see how it turns out. Note that the Settings value even overrides explicit "hh"/"HH" notation in a NSDateFormat format string. – Hot Licks Jan 21 '13 at 22:59

1 Answers1

4

There's a few methods. See my question here Detect iPhone 24-Hour time setting Basically you set a time and check the string for am or pm

Community
  • 1
  • 1
Darren
  • 10,182
  • 20
  • 95
  • 162