Date Picker always changes to the previous day
See original GitHub issueBug report
Describe the bug
When selecting a date, the DatePicker always changes the previous day
To Reproduce
- Setup a list with a
timestamp
orderDate: timestamp(),
- create a new record
- select a date
- date will change to the previous day
Expected behaviour
I expect the date a selected to continue to be the date I selected
Screenshots
System information
- OS: macos
- Browser: chrome & brave
Additional context
The date stored in the database also seems to be the new date “choosen” by the DatePicker…
IOW:
- If I’m in MST and I select
7/15/2021 07:00
- The UI updates to
7/14/2021 07:00
- I save
- The database displays
2021-07-14 13:00:00
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:13 (5 by maintainers)
Top Results From Across the Web
datepicker date off by one day - Stack Overflow
The reason you're off by day is because UTC time is for a timezone that is ahead of yours. (Since you didn't also...
Read more >DatePicker - date selected is previous day if changing month ...
open a datepicker (opens up in november); move to next or previous month (ex. move to december); select a date (ex. december, 12)....
Read more >Date Picker showing one day earlier, but there is no history of ...
You can see in the history that they were set correctly, but when we look at them the dates are off (but there...
Read more >changing selected date should ALWAYS update text input
With the current datepicker, selecting a different year/month using the dropdowns does NOT cause the text in the input field to update.
Read more >Date picker shows the previous day in Report New UI if the ...
1. Make sure to select the system timezone as UTC+10. 1. Create a new report for any table, for example the Incident table....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m running into a similar issue, but the dates saved in my DB are correct (as in, they are the ones I clicked).
Inspecting the picker with React devtools shows that the date picker is getting the date I clicked as its
value
prop, but just displaying the wrong date.It looks to be caused by this line: https://github.com/keystonejs/keystone/blob/58f525d9118471abb434bf912dd557d282c87250/design-system/packages/fields/src/DatePicker/index.tsx#L86
Formatter code:
Update I checked this in my console and was able to recreate the issue:
Another fun update Looks like using
-
as the delimiter in theDate
constructor causes JS to treat it as an ISO date or something, so the timezones get weird. But using/
treats it like a calendar date.@bladey I posted another bug report for this in Slack, but the issue still exists and has not been addressed 😢 https://keystonejs.slack.com/archives/C01STDMEW3S/p1648051507931239
Our experience is the exact same as others.
Upon closer inspection of the DatePicker component in Keystone, the value passed to the component is correct.
However the date information given to
aria-label
andchildren
is incorrect. In our case it is always off by 1 day and 5 hoursDatabase Value
UI Display
This is a critical bug IMO 😕 It’s causing massive confusion for our clients in the medical field who are relying on the application we built to deliver accurate information.