Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePicker display incorrect selected date when dateFormat using "YYYY-MM-dd". #5388

Open
Verto-dev opened this issue Feb 5, 2025 · 2 comments

Comments

@Verto-dev
Copy link

DatePicker display incorrect date when dateFormat using "YYYY-MM-dd",
affected date is only every year end of December (So far I notice)

You may try select the date on 29 Dec 2024

Expected Result
2024-12-29

Display Result
2025-12-29

Image

The package I installed and updated
Previous Version: 6.3.0 (Bug Affected)
Current Version: 8.0.0 (Bug Affected)

@tlehtimaki
Copy link

Could not replicate this on 8.0.0 or 7.6.0, or then I missed something. Could there be a bit more then meets the eye? I would encourage to post some more code as context or even better a reproduction example running somewhere.

@Verto-dev
Copy link
Author

Please take a look the video:

Screen.Recording.2025-02-06.at.10.08.41.AM.mov

I was using dateFormat="YYYY-MM-dd" in datePicker.
To make it clear I display the selected state value above the DatePicker Component.
Actually the selected state value is correct, but the DatePicker selected value show incorrect date.

below is my code:

<>
{JSON.stringify(selected)}
<DatePicker
selected={selected}
className="block w-full rounded-md border-0 px-3 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
onChange={(date) => {
onChange({ stateKey, date, index });
}}
dateFormat="YYYY-MM-dd"
showMonthDropdown
showYearDropdown
dropdownMode="select"
onKeyDown={(e) => {
e.preventDefault();
}}
disabled={disabled}
/>
</>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants