-
Notifications
You must be signed in to change notification settings - Fork 1k
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
pickadate adding +1 to month #391
Comments
This issue arises due to the assignment of data-value AND value attribute and is the same issue mentioned in pull request #386 |
It was pointed out to me today that it is more likely an issue with JavaScript rather than pickadate. JavaScript indexes months from 0 - 11 rather than the more usual and obviously too boring 1 - 12. Therefore a month with number 04 is indeed May and not April. This question on SO suggests a workaround is using the formats |
Right the cause if the issue is the month indexing of JavaScript. According to the docs, pickadate should parse the value given in the data-value attribute with one-based indexing, when a formatSubmit is given. Currently this doesn't work when also the value="" attr is given. The above mentioned pull request resolves that |
+1 for this one. Support for iso8601 format yyyy-mm-dd would be awesome! |
I fixed it be removing the !options.fromValue from line 582 in picker.date.js. I tested and if value is a string, I would always assume that month needs monthIndex = 1. The only exception to that is if it is not a string in the set value. line 582
|
Thanks for the possible solutions everyone. Closing this in favor of #358 PR |
I have php print a date in the
data-value
attribute of the datepicker input in the formatY-m-d
. I have set theformatSubmit
property toyyyy-mm-dd
and yet the date that comes out in the datepicker is one month more than the date indata-value
.I can visually verify, by looking at the source, that the date gets printed correctly by php as
2014-04-07
, for instance, but pickadate for some reason considers it2014-05-07
.here's my code if it helps:
and js:
The text was updated successfully, but these errors were encountered: