How to confirm the date? I do not mean the format, but the logic. For example: February 30, invalid date.
var date = new Date("2015-02-29T13:02:49.073Z");
Returns 2015-03-01T13: 02: 49.073Z (March 1).
But I need information that this date (input) is not valid.
Edit: Tested in Chrome. Firefox returns an "invalid date". But not to parse. Only when a date is used (e.g. toISOString ()) is an exception thrown.
try { var date = new Date("2015-02-29T13:02:49.073Z"); console.log(date.toISOString()); } catch(e) { console.log("error: " + e.message); }
Firefox:
wrong date
Chrome:
(nothing, just switched to the next date.)
Summary: browser dependent. Therefore, it is not recommended to use.
Jsfiddle example
source share