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

Input displaying one day off #14

Open
JMcAmmond opened this issue Jul 17, 2019 · 4 comments
Open

Input displaying one day off #14

JMcAmmond opened this issue Jul 17, 2019 · 4 comments

Comments

@JMcAmmond
Copy link

When selecting a date, the value is being returned correctly but it displays as one day off. This is probably because when the date objects are built they accept a string that doesn't account for time zones.

@biomiker
Copy link

I'm still seeing this issue. I initialize with selectedDate='2000-01-20', and the dropdowns show January 19 2000.

@biomiker
Copy link

@JMcAmmond is right, it relates to Time Zones. Specifically, the Date(selectedDate) constructor which Mozilla recommends not using: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

This issue is probably browser and data dependent but will reproduce on Chrome when using the recommended yyyy-mm-dd format. A workaround is to use slashes instead of dashes as the delimiter; this causes Date.parse to interpret the date in local time. Adding .replace(/-/g, '/') to my date string worked well.

@ssxv
Copy link
Owner

ssxv commented Sep 30, 2020

@biomiker Is this still a problem ? Do you have a workaround ?

@biomiker
Copy link

The workaround I mentioned on Jul 31 is still necessary. I use yyyy/mm/dd instead of yyyy-mm-dd.

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

3 participants