0

I've found some very strange behaviour in UIDatePicker: in my iPhone's settings I've select 24-h time but UIDatePickerstill shows 12-h time.

The local of UIDatePicker is default (based on user settings).

How to reproduce:

Preconditions:

  • iPhone language should be English
  • 24 hours format should be set
  • Timezone should be set as automatic
  • iPhone region: Ukraine

Steps:

  1. Change iPhone language to Ukrainian(haven't tested with other languages)
  2. Change timezone to Manual
  3. Switch 24-h time format to 12-h
  4. Switch 12-h time format to 24-h

As a result, we get the following: screenshot

Question: Is it the iOS bug or just my mistake?

Thank you for any suggestions.

  • 1
    Compare https://stackoverflow.com/q/1151335/1187415 and https://stackoverflow.com/a/6230569/1187415 – Martin R Nov 16 '18 at 13:15

1 Answers1

0

You can set the locale to auto update based on the user preferences like this

let datePicker = UIDatePicker()
datePicker.locale = Locale.autoupdatingCurrent
Ramon Vasconcelos
  • 1,466
  • 1
  • 21
  • 28