Home > Software design >  SwiftUI - Why is the date format not consistent?
SwiftUI - Why is the date format not consistent?

Time:02-19

I'm using enter image description here enter image description here

This is the code I use to generate the date picker:

DatePicker("", selection: $selectedDate, displayedComponents: [.date, .hourAndMinute])
        .datePickerStyle(CompactDatePickerStyle())
        .labelsHidden()
        .clipped()

CodePudding user response:

As far as I know this was a bug associated with the datepicker. Seems that it is still not fixed. There was a workaround for that as follows.

DatePicker("", selection: $selectedDate, displayedComponents: [.date, .hourAndMinute])
        .datePickerStyle(CompactDatePickerStyle())
        .labelsHidden()
        .clipped()
        .id(selectedDate)
  • Related