This morning, I read yuanyou's article once every eight hundred years ......, I thought if it was the first time in eight hundred, I used js to verify it myself;
You can use the following methods to determine whether there are five Saturday, five Saturday, and five Saturday: 1: The month must have 31 days.
2: The first day of the month must be the day of the week 5. (My judgment is that the last day is Sunday, and the last day is to facilitate the determination of the number of days in the month)
<Script>
// Move back one month
Function prevMonth (thisMonth, thisYear ){
If (thisMonth = 1 ){
ThisM = 12;
ThisY = (thisYear-1 );
}
Else {
ThisM = (thisMonth-1 );
ThisY = thisYear;
}
}
// Move forward one month
Function nextMonth (thisMonth, thisYear ){
If (thisMonth = 12 ){
ThisM = 1;
ThisY = (thisYear + 1)
}
Else {
ThisM = (thisMonth + 1 );
ThisY = thisYear;
}
}
// Convert to short Date Format
Function to1_date (date ){
Var dateStr = date. getFullYear () + "-" + (date. getMonth () + 1) + "-" + date. getDate ();
Return dateStr;
}
Var dtNow = new Date ();
Var thisM = dtNow. getMonth () + 1;
Var thisY = dtNow. getFullYear ();
Var arrayRecord = [];
While (thisY> = 1900 ){
PrevMonth (thisM, thisY );
Var lastDayOfPrevMonth = new Date (thisY, thisM, 0 );
If (lastDayOfPrevMonth. getDay () = 0 & lastDayOfPrevMonth. getDate () = 31 ){
ArrayRecord. push (to1_date (lastDayOfPrevMonth ));
}
}
Document. write (arrayRecord. join ("\ r "));
</Script>
The previous February has five Friday, five Saturday, and the five Thursday are:
2005-7
Thank you for leaving a message, please declare the source (http://www.cnblogs.com/flowerszhong ).