, , "2012-01-01", GMT 00:00:00. , , , , 31 .
, , Date ( Date.parse, ), . ISO 8601 ISO. , ECMAScript ed 3 (IE 8 ). ES5 , UTC ( ISO). ECMAScript 2015, , , , TC39 , UTC, ( - , ).
So, if you want consistency, manually enter the date strings, for example. to treat the ISO 8601 date as local, use a function such as:
function parseISOLocal(s) {
var b = s.split(/\D/);
var d = new Date(b[0], --b[1], b[2]);
return d && d.getMonth() == b[1]? d : new Date(NaN);
}
var s = '2012-01-01';
document.write(parseISOLocal(s))
Run codeHide result source
share