Javascript Date -> numeric vs string -
var date1 = new date('1900-01-01'); console.log(date1);
yields: "mon jan 01 1900 01:00:00 gmt+0100 (w. europe standard time)"
var date2 = new date(1900,1,1); console.log(date2);
yields: "thu feb 01 1900 00:00:00 gmt+0100 (w. europe standard time)"
but don't understand why!
you can see month difference since when pass individual components (year, month, day, etc) date
object constructor, have consider month parameter should start 0
:
console.log( new date('1900-01-01').getmonth() ); // 0
other jan/feb there shouldn't differences in dates.
mdn: https://developer.mozilla.org/en/docs/web/javascript/reference/global_objects/date
Comments
Post a Comment