I can't tell what the problem is here because I have implemented the react datetime picker as per the documentation, but when I select a date it shows an invalid date Uncaught Error: Invalid date: 17/01/ 2023
, what did I do 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 more attributes based on SO's ans https://stackoverflow.com/a/70183380/15178267
You should change this line again and it will work