-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pickers] Some LocalizationProvider dateFormats are barely used #16417
Comments
import * as React from 'react';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
import { useUtils } from '@mui/x-date-pickers/internals';
function FormattedDatePicker() {
const { formats } = useUtils();
return <DateTimePicker format={formats.keyboardDateTime} />
}
export default function FirstComponent() {
return (
<LocalizationProvider
dateAdapter={AdapterDayjs}
dateFormats={{ keyboardDateTime: 'DD.MM.YYYY | HH:mm' }}
>
<FormattedDatePicker />
</LocalizationProvider>
);
} |
Hello @mspiess
I'm adding the issue to our grooming board for the team to find the best solution. 😉 |
Hello again @mspiess. We are not very fond of the Have you considered using const theme = createTheme({
components: {
MuiDateTimePicker: {
defaultProps: {
format: 'DD.MM.YYYY | HH:mm'
}
}
}
}); |
Hello @LukasTy,
I feel like that issue could be elegantly solved, if the dateFormats were allowed to reference their respective "subformats" somehow.
Not yet. I'm not sure if that's feasible, given that the theme would have to be re-created whenever the locale changes. |
Steps to reproduce
Steps:
Current behavior
The date is displayed in the default format, e.g.
01/08/2025 12:00 AM
.Expected behavior
The date should be displayed in the
keyboardDateTime
format:01.08.2025 | 12:00
Context
I'm trying to change the format for all DateTimePickers given a certain locale.
This could be achieved through the
format
prop on theDateTimePicker
component, but that would have to be set on every component.The
dateFormats
seem to exist to solve this very problem, but many (fullTime
&keyboardDateTime
+ 12h/24h variants on each) seem to be unused beside outside somearia-
labels,This is despite their jsdoc claiming "Used in the date-time fields".
Your environment
npx @mui/envinfo
Search keywords: dateFormats AdapterFormats keyboardDateTime
The text was updated successfully, but these errors were encountered: