代码改变世界

【JavaScript】JS获得指定时间当前月的天数

2010-05-19 17:21  Peter Jin  阅读(1250)  评论(0编辑  收藏  举报
【要点】JS获得指定时间当前月的天数
js实现核心代码如下:
1 function getMonthDays(selectedDate)
2 {
3     var year = selectedDate.substring(0,4); 
4     var month= selectedDate.substring(5,7);   
5     var d = new Date(year, month, 0); 
6     var daysCount = d.getDate(); 
7     return daysCount;
8 }