function GetDaysInMonth(month, year)
{
return 32 - new Date(year, month, 32).getDate();
}
好吧,我不明白这是什么,具体干什么的,这一部分:这个“日月”功能如何工作?
new Date(year, month, 32).getDate();
我知道什么getDate()
呢,后来我在JavaScript抬头Date
但在这个特殊的例子,我不你明白为什么你会在这里传球32次。这怎么可能回到你传递给它的任何月份和年份的天数?
实际上它是在二月31日返回的,所以这件事情甚至都不起作用。我只是生气,因为我的老板只是告诉我如何减少30行代码,但是他告诉我使用的fing函数甚至不起作用!不是我无法修复它,但你知道有时候,代码评论是如何承认asswipes的。 – PositiveGuy 2009-11-06 18:45:43
我应该刚刚查过这个方法,它被盗了:http://snippets.dzone.com/posts/show/2099 – PositiveGuy 2009-11-06 18:55:36