0

I am creating a react component that allows user to pick a date using a simple "input" field with "date" type. The problem is that I can't manage to display dates in the format "dd/mm/yyyy". it is always displayed as "mm/dd/yyyy".

const [date, setDate] = useState(new Date());

    const handleChange = (event) => {
        setDate(new Date(event.target.value));
    };
    const formattedDate = date.toISOString().slice(0, 10);

    console.log("Date", formattedDate)

return(
<input type="date" value={formattedDate} onChange={handleChange} />
)
Firda el.
  • 13
  • 2
  • The format is based on OS/Browser/Regional settings etc. See [Is there any way to change input type="date" format?](https://stackoverflow.com/questions/7372038/is-there-any-way-to-change-input-type-date-format) for more info. – sikado Mar 05 '23 at 11:02

0 Answers0