javascript正在创建日期错误的月份

使用Mozilla Firefox Firebug:

var myDate = new Date(2012, 9, 23, 0,0,0,0);
myDate;

日期{Tue Oct 23 2012 00:00:00 GMT-0400(Eastern Daylight Time)}

为什么javascript会在错误的月份创建日期?

不,javascript的日期月份从0开始,所以9是10个月,是10月

Reference

new Date(year, month [, day, hour, minute, second, millisecond]);

[…]

month
Integer value representing the month, beginning with 0 for January to 11 for December.

http://stackoverflow.com/questions/12254333/javascript-is-creating-date-wrong-month

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:javascript正在创建日期错误的月份