Invalid dates are parsed as valid
See original GitHub issueInvalid dates are parsed resulting in incorrect values
e.g,
const dt = dayjs(‘1993-51-11’)
dt.isValid() returns true and dt.format('YYYY-MM-DD') returns 1997-03-11
const dt = dayjs(‘1993-51-41’)
dt.isValid() returns true and dt.format('YYYY-MM-DD') returns 1997-04-10
infact dayjs('1993-08-21', 'YYYY/MM/DD') returns true for isValid()
isValid() should return false for all these
Information
- Day.js Version: v1.9.6
- OS: macOS 11 BigSur
- Browser: chrome 86
- Time zone: GMT
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (5 by maintainers)
Top Results From Across the Web
Invalid date ArgumentError and incorrect parse on a valid date?
Given your input, Date.parse is parsing your dates assuming they are in the format YY/MM/DD , so when it try to parse 11/25/08...
Read more >RangeError: invalid date - JavaScript - MDN Web Docs
The JavaScript exception "invalid date" occurs when a string leading to an invalid date has been provided to Date or Date.parse() .
Read more >C# DateTime.TryParse() could parse invalid date
TryParse() can parse 7.16 where as 7.16 is not a valid date. is it any bug? rather this code properly worked. bool status...
Read more >Validation
Returns a boolean indicating whether the Dayjs 's date is valid. Non-strict check. Only checks if the value could be parsed to a...
Read more >Check If a String Is a Valid Date in Java - Baeldung
Java has provided facilities to format and parse dates since the beginning. This functionality is in the DateFormat abstract class and its ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Do remember this dependent on CustomParseFormat plugin to work https://day.js.org/docs/en/parse/string-format
For the people that still are struggling with this. As the other people mentioned you need
CustomParseFormat