0

I cannot tell what the problem is here, because i have followed the documetation to implement that react date time picker, but when i select a date it shows invalid date Uncaught Error: Invalid date: 17/01/2023, what am i doing wrong

import DateTimePicker from 'react-datetime-picker';
function ServiceDetail() {
    const [date, setDate] = useState(new Date());
    return (
      <DateTimePicker
        className="float-start"
        style={{ border: "none" }}
        value={date}
        dateFormat="dd/MM/yyyy"
        onChange={(date) => {
          const d = new Date(date).toLocaleDateString("fr-FR");
          console.log(d);
          setDate(d);
        }}
    name="booking_date"
/>;
)

i added some more attributes accoriding to the SO's ans https://stackoverflow.com/a/70183380/15178267

1 Answers1

-1
const [date, setDate] = useState(new Date().toLocaleDateString('fr-FR'));

You should change this line again it will work

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 01 '23 at 09:41