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
const [date, setDate] = useState(new Date().toLocaleDateString('fr-FR'));
You should change this line again it will work