Sometimes, we want to check if date is a valid one with JavaScript.
In this article, we’ll look at how to check if date is a valid one with JavaScript.
How to check if date is a valid one with JavaScript?
To check if date is a valid one with JavaScript, we can use the moment.js’ isValid
function.
For instance, we write
const date = moment("2022-10-19").isValid();
to call moment
with a date string.
Then we call isValid
to check if the date string is a valid one.
Conclusion
To check if date is a valid one with JavaScript, we can use the moment.js’ isValid
function.