Localized dates
Date and Time Pickers support formats from different locales.
Getting started
The default locale of MUI is English (United States). If you want to use other locales—follow the instructions below.
Set a custom locale
With dayjs
For dayjs
, import the locale and then pass its name to LocalizationProvider
:
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import 'dayjs/locale/de';
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale="de">
{children}
</LocalizationProvider>;
With date-fns
For date-fns
, import the locale and pass it to LocalizationProvider
:
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import de from 'date-fns/locale/de';
<LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={de}>
{children}
</LocalizationProvider>;
With luxon
For luxon
, pass the locale name to LocalizationProvider
:
import { AdapterLuxon } from '@mui/x-date-pickers/AdapterLuxon';
<LocalizationProvider dateAdapter={AdapterLuxon} adapterLocale="de">
{children}
</LocalizationProvider>;
With moment
For moment
, import the locale and then pass its name to LocalizationProvider
:
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
import 'moment/locale/de';
<LocalizationProvider dateAdapter={AdapterMoment} adapterLocale="de">
{children}
</LocalizationProvider>;
12h/24h format
All the time and datetime components will automatically adjust to the locale's time setting, i.e. the 12-hour or 24-hour format.
You can override the default setting with the ampm
prop:
Custom formats
Custom field format
The fields have a default format that depends on the picker being used, the views enabled, and the 12h/24h format.
If this default format does not suit you, you can customize it using the format
prop:
Field-supported formats
Some formats might not yet be supported by the fields. For example, they don't support day of the year or quarter.
Here is the list of the currently supported formats:
The year
- ✅ 2-digits values (e.g:
23
) - ✅ 4-digits values (e.g:
2023
) - ❌ Values with ordinal (e.g:
2023th
)
- ✅ 2-digits values (e.g:
The month
- ✅ 1-based digit (e.g:
08
) - ✅ Multi-letter values (e.g
Aug
,August
) - ❌ 1-letter values (e.g:
A
) because several months are represented with the same letter
- ✅ 1-based digit (e.g:
The day of the month
- ✅ 1-based digit values (e.g:
24
) - ✅ 1-based digit values with ordinal (e.g:
24th
)
- ✅ 1-based digit values (e.g:
The day of the week
- ✅ 0-based digit values (e.g:
03
) - ✅ 1-based digit values (e.g:
04
) - ✅ Multi-letter values (e.g:
Tue
,Tuesday
) - ❌ 1-letter values (e.g:
T
) because several days of the week are represented with the same letter
- ✅ 0-based digit values (e.g:
The hours
- ✅ 0-based 12-hours values (e.g:
03
) - ✅ 0-based 24-hours values (e.g:
15
) - ❌ 1-based values (e.g:
24
instead of00
)
- ✅ 0-based 12-hours values (e.g:
The minutes
The seconds
The meridiem
If you need to use some format that is not yet supported, please open an issue describing what is your exact use case. Some new formats might be supported in the future, depending on the complexity of the implementation.
Respect leading zeros in fields
By default, the value rendered in the field always contains digit zeros, even if your format says otherwise.
You can force the field to respect your format information by setting the shouldRespectLeadingZeros
prop to true
.
Custom field placeholder
When a section is empty, the fields displays its placeholder instead of an empty value.
For example, if you did not fill any value for the year
section, the field will render the year placeholder.
These placeholders are based on your current component localization, not on your date localization.
English locale (default)
German locale
For more information on how to define your component localization, check out the Translated components page.
Custom toolbar format
To customize the format used in the toolbar, use the toolbarFormat
prop of the toolbar slot.
Custom day of week format
Use dayOfWeekFormatter
to customize day names in the calendar header.
This prop takes the short name of the day provided by the date library as an input, and returns it's formatted version.
The default formatter only keeps the first letter and capitalises it.
The example below adds a dot at the end of each day in the calendar header:
Use UTC dates
With dayjs
To use UTC dates with dayjs
, you have to:
Extend
dayjs
with itsutc
plugin:import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; dayjs.extend(utc);
Pass
dayjs.utc
toLocalizationProvider
dateLibInstance
prop:<LocalizationProvider dateAdapter={AdapterDayjs} dateLibInstance={dayjs.utc}> {children} </LocalizationProvider>
Always pass dates created with
dayjs.utc
:<DateTimePicker // ✅ Valid props value={dayjs.utc()} minDate={dayjs.utc().startOf('month')} // ❌ Invalid props value={dayjs()} minDate={dayjs().startOf('month')} />
Value: null
With moment
To use UTC dates with moment
, you have to:
Pass
moment.utc
toLocalizationProvider
dateLibInstance
prop:<LocalizationProvider dateAdapter={AdapterMoment} dateLibInstance={moment.utc}> {children} </LocalizationProvider>
Always pass dates created with
moment.utc
:<DateTimePicker // ✅ Valid props value={moment.utc()} minDate={moment.utc().startOf('month')} // ❌ Invalid props value={moment()} minDate={moment().startOf('month')} />
Value: null
Other libraries
UTC support is an ongoing topic.
We will update the documentation with examples using other date libraries once the support for them will be sufficient.