const isValidDate = function(date) {
return (new Date(date) !== "Invalid Date") && !isNaN(new Date(date));
}
const isValid = !Number.isNaN(new Date(timestamp).getTime())
isNaN(d.getTime())
const validDate = !isNaN(Date.parse('foo'))
if (Object.prototype.toString.call(d) === "[object Date]") {
// it is a date
if (isNaN(d.getTime())) { // d.valueOf() could also work
// date is not valid
} else {
// date is valid
}
} else {
// not a date
}