Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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