I have the following date picker:
DatePicker("Time", selection: $wakeUp, displayedComponents: .hourAndMinute)
That would be using the 24h format by default like this:
How can I set it to am/pm format like this:
I tried the following:
DatePicker("Time", selection: $wakeUp, displayedComponents: [.hourAndMinute, .dateFormat = "hh:mm a"])
but it's not working. How can I have the time picker (only the time, not date) in am/pm format?
CodePudding user response:
The picker will respect the locale. So, if you what to overrule the system settings you can set the desired locale on the picker like this:
picker.locale = Locale.init(identifier: "en")