Skip to content

Instantly share code, notes, and snippets.

@shigwata
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save shigwata/55099279451b43937b4d to your computer and use it in GitHub Desktop.

Select an option

Save shigwata/55099279451b43937b4d to your computer and use it in GitHub Desktop.
Check date in JavaScript
function isValidDate(year, month, day) {
var d = new Date(year, month, day);
if ((d.getFullYear() != year) ||
(d.getMonth() != month) ||
(d.getDate() != day)
) {
return false;
}
return true;
}
// the months start with 0 in JavaScript
// 2011-06-31
console.log(isValidDate(2011,5,31));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment