I just started learning front-end technologies (React) and facing an issue with react date picker API.
Whenever I select a date from the UI, it displays correctly on the UI but when I bind the date to send it over to the server to save the record, it sends a previous date with a timestamp.
For example: If I select today's date i.e. 14 April 2022 from the UI, the actual date is bonded something like 13 April 2022T06:33:11.
dob: "2022-04-13T18:30:00.000Z"
I have tried to debug the issue but did find anything relevant, but when I console.log the date, it prints the same date as selected from the UI.
Here is the code that I implement for data picker.
import DatePicker from "react-datepicker";
const [dob, setDob] = useState("");
<DatePicker
className="form-control"
minDate={new Date("1945/08/15")}
maxDate={new Date()}
selected={dob}
onChange={(date) => setDob(date)}
showMonthDropdown
showYearDropdown
dropdownMode="select"
/>
What's wrong with my code?