ios – Utilizing SwiftUI how can I power a DatePicker to make use of the 24 Hour date format slightly than the locale the consumer has on their gadget

0
195


I’m attempting to power my SwiftUI DatePicker to override the consumer’s settings and solely show a 24 hour time format. This could be related in an aviation associated app. I’ve seen some outdated posts utilizing UIDatePicker and overriding the locale, nonetheless that does not work for the precise gadget utilizing the next:

DatePicker("Begin Time", choice: $startTime, displayedComponents: DatePickerComponents.hourAndMinute)
    .atmosphere(.locale, Locale.init(identifier: "en_GB"))

After I run this on my gadget with area set to US, it nonetheless shows hours and minutes with am/pm. I’ve tried different locales reminiscent of en_DK however nonetheless shows am/pm.

I can implement a customized popover and wheel spinners to imitate this, however that runs into points on an iPhone going fullScreen. I am certain there are different work arounds utilizing customized logic, however I used to be questioning if there’s anyway to power the native DatePicker to make use of am/pm.