Skip to content

Instantly share code, notes, and snippets.

@corymartin
Created April 21, 2012 05:33
Show Gist options
  • Select an option

  • Save corymartin/2434311 to your computer and use it in GitHub Desktop.

Select an option

Save corymartin/2434311 to your computer and use it in GitHub Desktop.
isInvalidDate()
function isInvalidDate( /*Date*/date ) {
if (date == null || !(date instanceof Date)) return true;
var ts = date.getTime();
if (ts !== ts) return true; // NaN
var str = date.toString();
return str === 'Invalid Date' || str === 'NaN';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment