<script language="JavaScript">
function getMonthDays(year,month)
{
var date1 = new Date(year, month-1, 1);
var returnValue = 0;
while(date1.getMonth()+1 == month)
{
returnValue++;
date1.setTime(date1.getTime()+1000*60*60*24);
}
return returnValue;
}
alert(getMonthDays(2004,2));
alert(getMonthDays(2005,2));
alert(getMonthDays(2005,7));
</script>
function getMonthDays(year,month)
{
var date1 = new Date(year, month-1, 1);
var returnValue = 0;
while(date1.getMonth()+1 == month)
{
returnValue++;
date1.setTime(date1.getTime()+1000*60*60*24);
}
return returnValue;
}
alert(getMonthDays(2004,2));
alert(getMonthDays(2005,2));
alert(getMonthDays(2005,7));
</script>
解决方案 »
- js对象的问题,学艺不精,特来请教。。
- 请教一个UBB转换代码中的正则问题。
- 请教一个JS里<a href="#" conclick="">的用法问题,急急急!
- 想做一个类似于任务栏那种效果的DIV,多多指教,谢谢
- 在一个打开的模式窗口中新open一个窗口丢失SESSION
- 如何隐藏弹出窗口的水平滚动条??? 在线等
- 一个多选下拉框,我怎么用js知道用户都选择了这个多选下拉框的哪几项呢?
- 如何实现这个效果呀?我的代码错在哪儿了,谢谢大家给予指正!
- 变值问题。
- Vue.js 引入阿里云播放器 问题
- 在一个文本框里输入一个数字n,在本页form中就出现n个文本框,这样的javascript咋写?急啊,在线等!!!
- *******js如何调用webservice(c#写的)查询数据库,然后返回查询结果???
dateObj必选项。要赋值为 Date 对象的变量名。dateVal必选项。如果是数字值,dateVal 表示指定日期与 1970 年 1 月 1 日午夜间全球标准时间 的毫秒数。如果是字符串,则 dateVal 按照 parse 方法中的规则进行解析。dateVal 参数也可以是从某些 ActiveX(R) 对象返回的 VT_DATE 值。year必选项。完整的年份,比如,1976(而不是 76)。month必选项。表示的月份,是从 0 到 11 之间的整数( 1 月至 12 月)。
function getMonthDays(year,month){
return new Date(year, month, 0).getDate();
}
alert(getMonthDays(2004,2));
alert(getMonthDays(2005,2));
alert(getMonthDays(2005,7));
</script>