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
There doesn't seem to be a way to handle either 2 or 4 digit years #2343
Comments
👍 This would be a very good feature. |
Cool, thanks. Any idea when it might appear? |
We're all volunteers here, so its hard to pin a timeline on anything. If it's urgent for you, feel free to make the modifications yourself and send a pull request. Thanks. |
Sorry if that sounded like hassling, it wasn't my intention. Yes, I normally would have made a pull request already actually, but it's going to take me a little while to understand what to change on this one! If I get there before you I'll submit a pull request :) |
😄 |
Very odd; I could have sworn this would default to use 2000. |
If we are to take that approach, then should't it use the |
In Firefox using moment("6/12/15").format("M/D/YYYY h:mm:ss A") I get 6/12/1915 instead of 6/12/2015? How do I fix this? |
@ppoisson parse it with an explicit format string as the second arg; right now you're just using the native |
Thanks! |
Would love to see it to, maybe as an additional langue-aware format. I'm currently using "l" and "L", but both use 4-digit-years, so I have to do manual checks for those formats additionally - which makes the locale-aware-formats kind of useless to me. |
Two digit years will use the parseTwoDigitYear function when parsing with the YYYY format. Closes moment#2343
Two digit years will use the parseTwoDigitYear function when parsing with the YYYY format. Closes moment#2343
I feel that the following snippet:
ought to return the date
2014-04-23
(using ISO for the avoidance of doubt), but instead it returns0014-04-23
, which is pretty unlikely to have been what the user intended.The opposite way round:
gives you
2020-04-23
, which isn't likely to have been what the user meant either...To maintain backwards compatibility, perhaps there should be another format specifier, e.g. a single
Y
that doesn't care whether it gets a 2 digit year or a 4 digit year, and returns something sensible either way.I.e., I want to be able to parse the user input and not care whether they used a 4 digit year or a 2 digit year, and use some sensible rules to return the date the user expected.
The text was updated successfully, but these errors were encountered: