更新时间:2022-11-13 21:54:57
1.您没有分享您尝试过的内容
2.您在多个论坛上发布了此内容
这是询问者的期望:
一个. 先尝试您要做什么!您可能会发现它并不难.
b.拟定看起来像问题/无法解决的问题,由您完成.
目前,您在这里有一个答案:获取星期日的数量在一个月内使用javascript [ ^ ]
它说:
1. You did not share what you tried
2. You posted this at multiple forums
Here is what is expected of enquirers:
a. TRY first what you want to do! You may find that it''s not that hard.
b. Formulate what was done by you that looks like an issue/not working.
For now, here, you have an answer: get number of sundays in a month using javascript[^]
It says:
function sundaysInMonth( m, y ) {
var days = new Date( y,m,0 ).getDate();
var sundays = [ 8 - (new Date( m +'/01/'+ y ).getDay()) ];
for ( var i = sundays[0] + 7; i < days; i += 7 ) {
sundays.push( i );
}
return sundays;
}
alert( sundaysInMonth( 10,2012 ) ); //=> [ 7,14,21,28 ]
alert( sundaysInMonth( 10,2012 ).length ); //=> 4
此外,在这里,了解如何在JavaScript中处理日期操作: MSDN :计算日期和时间(JavaScript) [ ^ ]
Further, here, learn how to handle date manipulations in JavaScript: MSDN: Calculating Dates and Times (JavaScript)[^]