Checking if a date is valid in javascript
JavascriptJavascript Problem Overview
> Possible Duplicate:
> Detecting an “invalid date” Date instance in JavaScript
Is there is a function IsDate()
in javascript?
Javascript Solutions
Solution 1 - Javascript
Try this:
var date = new Date();
console.log(date instanceof Date && !isNaN(date.valueOf()));
This should return true
.
UPDATED: Added isNaN
check to handle the case commented by Julian H. Lam