Javascript Date isValid()
// http://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript Date.prototype.isValid = function () { return this.getTime() === this.getTime(); }
Date.prototype.isValid = function() { return this.getTime() === this.getTime(); }; function twoDigits(value) { if (value < 10) { return '0' + value; }/*from w w w .j av a2 s.co m*/ return value; } exports.getMyDate = function(timestamp) { var date = new Date(timestamp * 1000); return date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate(); } exports.time = function() { var date = new Date(); return date.valueOf() / 1000; }
Date.prototype.isValid = function () { return this.getTime() === this.getTime(); };