Angular date picker: selected date is off by one day
Describe the bug
When selecting a date from the date picker the date form field value is set to one day before the selected date. For example, choosing 9.10.2022 from the picker will result in 8.10.2022 being displayed in the date form field.
Expected behavior
The correct date value should be set, i.e., the date set and displayed in the date form field should match the selected date from the picker.
Steps to reproduce the issue
- Open the date picker on a date field.
- Click on any day.
- See the value in the date field is off by one day compared to the day previously clicked on.
Screenshots
No response
In which browser are you experiencing the issue?
Google Chrome 106.0.5249.103
Framework
Angular
RendererSet
Material
Additional context
This issue occurs both in my own app and on the JSONForms Angular Material Playground (https://jsonforms-angular-seed.netlify.app/).
Possible cause: Maybe some time zone shenanigans are interfering here. For example it could be that we set the time to 00:00 of the selected day, but because of some automatic timezone consideration the day is then calculated to the day before.
I think you’re right. If I change my time zone to UTC, the date is correct.