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
精彩评论