How can I format date in x-date-picker?

93 Views Asked by At

I've tried to use

  • format="l"
  • format="m/d/yyyy"

I want this format m/d/yyyy, I mean I'd like the day and the month without zeroes. How I do that?

P.S.: I am using this datepicker in the material UI datagrid.

I tried to check in the dayjs/datepicker documentation.

Check it here https://codesandbox.io/s/hidden-waterfall-nsx3dt?file=/demo.tsx

1

There are 1 best solutions below

0
On

For avoiding zero from the beginning there's date field prop shouldRespectLeadingZeros, here the link to mui documentation on that

<DatePicker 
  label="Helper text example" 
  format="M/D/YYYY"
  slotProps={{ field: { shouldRespectLeadingZeros: true } }}
/>