Last active
December 23, 2020 11:44
-
-
Save dustinpoissant/b83750d8671f10c414b346b16e290ecf to your computer and use it in GitHub Desktop.
Determine if a string is a validate Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date.valid = function(str){ | |
var d = new Date(str); | |
return (Object.prototype.toString.call(d) === "[object Date]" && !isNaN(d.getTime())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date.valid=function(a){var b=new Date(a);return"[object Date]"===Object.prototype.toString.call(b)&&!isNaN(b.getTime())}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment