Skip to content

Instantly share code, notes, and snippets.

@dustinpoissant
Last active December 23, 2020 11:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinpoissant/b83750d8671f10c414b346b16e290ecf to your computer and use it in GitHub Desktop.
Save dustinpoissant/b83750d8671f10c414b346b16e290ecf to your computer and use it in GitHub Desktop.
Determine if a string is a validate Date
Date.valid = function(str){
var d = new Date(str);
return (Object.prototype.toString.call(d) === "[object Date]" && !isNaN(d.getTime()));
}
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