SwiftUI DatePicker Month Display Conundrum

Viewed 288

Help! Depending on the selected date, the displayed date for a Swift DatePicker with CompactDatePickerStyle shows the month ('Mar'):

Displaying Mar for month

Or shows the month number ('3'):

Displaying '3' for month

I want all dates to display with the month name (abbreviated or full).

Here's the complete application in Xcode version 12.4:

struct ContentView: View {
    @State var date: Date = Date()
    var body: some View {
            DatePicker("Date", selection: $date)
                .datePickerStyle(CompactDatePickerStyle())
                .padding()
    }
}
0 Answers
Related