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

React-Datepicker used inside Formik form and initialized to Date() returns timestamp on selection #3133

Closed
eugeneborodkin opened this issue Aug 10, 2021 · 2 comments
Labels

Comments

@eugeneborodkin
Copy link

eugeneborodkin commented Aug 10, 2021

Describe the bug
I have a Day-based React-Datepicker used inside a Formik form, which may or may not be relevant (I followed this small Formik wrapper). When the React-Datepicker is initialized to a form value that has a timestamp, such as new Date(), then any day selection returns the current timestamp. On the other hand, when it's initialized to something like NULL, any day selection returns 00:00:00. I need zero-time 00:00:00 returned in both of these cases.

To Reproduce
CodeSandBoxIO Demo:
https://codesandbox.io/s/proud-dust-gb25u
In this demo:

  1. Datepicker 1 in Formik form initialized to new Date(). Note that any date selection includes the current timestamp in the value.
  2. Datepicker 2 in Formik form initialized to NULL. Note that any date selection includes the 00:00:00 timestamp.

Expected behavior
Even if the DatePicker is initialized to a form value of new Date(), it should still return 00:00:00 on any Day selection. Regardless of how it is initialized, the value set by a day-based React-DatePicker such as in this example should always be 00:00:00 (no time, just the date).

@adyz
Copy link

adyz commented Aug 25, 2021

This is strange indeed, it's not caused by Formik, I've modified your sandbox and added some datepickers that use state instead on formik and the same happens here also: https://codesandbox.io/s/affectionate-engelbart-sl61c

@stale
Copy link

stale bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 2, 2022
@stale stale bot closed this as completed Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants