One js Day (8) gets the day of a month, the day of the month, the day of week 1, and the day of the month.

Source: Internet
Author: User

Obtain the day of a month, the day of the month, and the day of the month.
[Javascript]
Var Nowdate = ("2012-11-22"). split ("-"), // obtain a date
NowYear = parseInt (Nowdate [0]), // a year
NowMonth = parseInt (Nowdate [1]), // a month
Nowday = parseInt (Nowdate [2]), // one day
Date = new Date (),
Weekday = new Array (7 );
Weekday [0] = "Sunday ";
Weekday [1] = "Monday ";
Weekday [2] = "Tuesday ";
Weekday [3] = "weekday ";
Weekday [4] = "Thursday ";
Weekday [5] = "Friday ";
Weekday [6] = "Saturday ";
Date. setFullYear (NowYear); // set the current year to a certain year
Date. setMonth (NowMonth-1); // set the current month to a month
Date. setDate (Nowday); // set the current day to a certain day
Document. write (NowYear + "year" + NowMonth + "month" + Nowday + "is" + weekday [date. getDay ()] + "<br/> ");
 
Date. setDate (1); // set the current date to the first day of the month
Document. write (NowYear + "year" + NowMonth + "Month 1 is" + weekday [date. getDay ()] + "<br/> ");
 
Date. setMonth (date. getMonth () + 1); // month + 1 (1st day of next month)
Var LastDay = new Date (date-3600000*24); // day-1 (that is, the last day of the month)
Document. write (NowYear + "year" + NowMonth + "month total" + LastDay. getDate () + "day <br/> ");

Var Nowdate = ("2012-11-22"). split ("-"), // obtain a date
NowYear = parseInt (Nowdate [0]), // a year
NowMonth = parseInt (Nowdate [1]), // a month
Nowday = parseInt (Nowdate [2]), // one day
Date = new Date (),
Weekday = new Array (7 );
Weekday [0] = "Sunday ";
Weekday [1] = "Monday ";
Weekday [2] = "Tuesday ";
Weekday [3] = "weekday ";
Weekday [4] = "Thursday ";
Weekday [5] = "Friday ";
Weekday [6] = "Saturday ";
Date. setFullYear (NowYear); // set the current year to a certain year
Date. setMonth (NowMonth-1); // set the current month to a month
Date. setDate (Nowday); // set the current day to a certain day
Document. write (NowYear + "year" + NowMonth + "month" + Nowday + "is" + weekday [date. getDay ()] + "<br/> ");

Date. setDate (1); // set the current date to the first day of the month
Document. write (NowYear + "year" + NowMonth + "Month 1 is" + weekday [date. getDay ()] + "<br/> ");

Date. setMonth (date. getMonth () + 1); // month + 1 (1st day of next month)
Var LastDay = new Date (date-3600000*24); // day-1 (that is, the last day of the month)
Document. write (NowYear + "year" + NowMonth + "month total" + LastDay. getDate () + "day <br/> ");

 

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.