CopyCodeThe Code is as follows: var getmonthweek = function (a, B, c ){
/*
A = d = current date
B = 6-W = there are still several days to finish the current week (not today)
Divide the sum of A + B by 7, which is the week of the current month.
*/
VaR date = new date (A, parseint (B)-1, C), W = date. getday (), D = date. getdate ();
Return math. Ceil (
(D + 6-W)/7
);
};
VaR getyearweek = function (a, B, c ){
/*
Date1 is the current date
Date2 is the first day of the year.
D indicates the number of days of the current year.
Use D + to divide the week gap on the first day of the current year by 7, which is the week of the current year.
*/
VaR date1 = new date (A, parseint (B)-1, C), date2 = new date (A, 0, 1 ),
D = math. Round (date1.valueof ()-date2.valueof ()/86400000 );
Return math. Ceil (
(D + (date2.getday () + 1)-1)/7
);
};
Document. Write (
"Today is the day of the month", getmonthweek (2007, 03, 19), "week <br \/>"
, "Today is the day of the year", getyearweek (2007, 03, 19), "Week"
);