'Material ui date picker formatting
I want show "Today" text instead of DD/MM/YYYY Eg: when we use datepicker browser show something like 20/1/2009 But I want "Today" instead of that date
Solution 1:[1]
Here is a working example where DatePicker
is initialized with today's date:
import * as React from 'react'
import TextField from '@mui/material/TextField'
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'
import { DatePicker } from '@mui/x-date-pickers/DatePicker'
export default function BasicDatePicker()
{
// initialized with today's date, new Date()
const [value, setValue] = React.useState(new Date())
return (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker
label="Date picker"
value={value}
onChange={(newValue) => setValue(newValue)}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | pez |