When the iPhone Language is non-English and I turn the "24-Hour Time" switch off, DateFormatter.localizedString always returns 12-Hour time.

How to reproduce the bug:

  1. Set iPhone Language to English.
  2. Set iPhone Language to Deutsch.
  3. Turn the "24-Hour Time" switch off.
  4. Turn the "24-Hour Time" switch on.
  5. Create the empty project with "Sing View App" template.
  6. Paste the following code: print(DateFormatter.localizedString(from: Date(), dateStyle: .none, timeStyle: .short)).
  7. Build and run the project. The output will be in 12-Hour Format. At this time the func is ignoring the "24-Hour Time" switch in the Settings.
  8. Set iPhone Language to English.
  9. Turn the "24-Hour Time" switch on.
  10. Set iPhone Language to Deutsch.
  11. Run the project. The output will be in 24-Hour Format. At this time the func result is correct.
  12. Turn the "24-Hour Time" switch off.
  13. Turn the "24-Hour Time" switch on.
  14. Run the project. The output will be in 12-Hour Format. At this time the func result is incorrect.

Replies

At this time the func is ignoring the "24-Hour Time" switch in the Settings.

That sounds like a straightforward bug to me, and I recommend that you file it as such.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

The problem ID is 50623228.