开发者

Javascript returning month as 9 where it is 10

I'm building today's date using a onclick event in JavaScript. When i set the .value prope开发者_JAVA技巧rty with:

var now = new Date;
...Value = now.getMonth() + "/" + now.getDate() + "/" + now.getYear(); 

this produces: 9/9/2009 I am expecting: 10/9/2009

This happens in both IE and Firefox. The system time on my computer is correct. Any ideas?


It's zero-based. January is month 0.

http://www.w3schools.com/jsref/jsref_getMonth.asp


getMonth() starts at 0.


The enumeration is 0 based.

0 = January
1 = Feb... etc

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜