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

moment('31-10-2021', 'YYYY-MM-DD').isValid() is true #5928

Open
UJPrasad opened this issue Sep 2, 2021 · 1 comment
Open

moment('31-10-2021', 'YYYY-MM-DD').isValid() is true #5928

UJPrasad opened this issue Sep 2, 2021 · 1 comment

Comments

@UJPrasad
Copy link

UJPrasad commented Sep 2, 2021

Describe the bug
moment('31-10-2021', 'YYYY-MM-DD').isValid() is giving true when it's not.

To Reproduce
Steps to reproduce the behavior:

  • moment('31-10-2021', 'YYYY-MM-DD').isValid() -- run it.

Expected behavior
moment('31-10-2021', 'YYYY-MM-DD').isValid() //false

@shreyngd
Copy link

shreyngd commented Sep 9, 2021

As mentioned in the doc,
YYYY : 4 or 2 digit year. Note: Only 4 digit can be parsed on strict mode

Pass the third param which sets the strict mode as true

moment('31-10-2021','YYYY-MM-DD',true).isValid() // false
moment('31-10-2021','DD-MM-YYYY',true).isValid() // true

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

2 participants