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正在创建日期错误的月份