Can I change the date text in a SwiftUI DatePicker?

41 Views Asked by At

I have a DatePicker and I want to change the text that is displayed for the date. So in this example, I want to change '13 Mar 2024' to be 'Today'.

        DatePicker(
            "What date?",
            selection: $myDate
        )

image saying "What Date?" and then "13 Mar 2024" and then "20:21"

I know how to change the "What date?" part, but that's not the part that I want to change.

And I know how to use a DateFormatter() to generate a String from a Date, but I can't see how to use a DateFormatter() in a DatePicker.

Does anyone know how to format the actual date part, without creating a whole new custom DatePickerStyle from scratch?

0

There are 0 best solutions below