Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Date object's default day
function createDateString(day, month, year) {
return year + '-' + month + '-' + day;
}
function validateDate(dateStr) {
var ourDate = new Date(dateStr);
if(/(Invalid)/.test(ourDate)) {
return false;
}
return true;
}
var firstDate = createDateString('01', '01', '1990');
console.log(validateDate(firstDate));
var secondDate = createDateString('', '01', '1990');
console.log(validateDate(secondDate));
var thirdDate = createDateString(null, '01', '1990');
console.log(validateDate(thirdDate));