The day of JavaScript computing is the week of this month.

Source: Internet
Author: User
Tags date1

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"
);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.