Swift change date picker language

13,279

You should assign loc to the date picker locale property:

let loc = Locale(identifier: "uk")
self.datePicker.locale = loc
Share:
13,279
Evgeniy Kleban
Author by

Evgeniy Kleban

Updated on July 22, 2022

Comments

  • Evgeniy Kleban
    Evgeniy Kleban almost 2 years

    I want to change format of month represent in my UIDatePicker. I tried:

    self.datePicker = UIDatePicker()
    self.datePicker.backgroundColor = .white
    self.datePicker.datePickerMode = .date
    let loc = Locale.init(identifier: "uk")
    var calendar = Calendar.current
    calendar.locale = loc
    self.datePicker.calendar = calendar
    

    After that, month representation suppose to be in ukranian, but it still in other language.

  • えるまる
    えるまる over 4 years
    Thanks for your answer, do you know way to change global locale so that each formatter would use it?
  • Ahmad F
    Ahmad F over 4 years