Home > Web Front-end > JS Tutorial > Detailed explanation of the use of js Calender control_javascript skills

Detailed explanation of the use of js Calender control_javascript skills

WBOY
Release: 2016-05-16 16:22:11
Original
1245 people have browsed it

I’ve been working on projects lately. The project is now finally in a stable state, just making modifications and changes. As a backend programmer, I have a really hard time. I have to write everything from web to mobile interfaces, all kinds of things. . . I finally had some free time in the past two days. I took a look at some functions about js date. Suddenly I thought of the calendar control, so I tried to write one. As a background programmer, my level is limited. Please take a look at it with a learning attitude. Let me write this example. . .

First, a commonly used date function: Date(year,month,day)

Copy code The code is as follows:

var date=new Date();

Get the year

Copy code The code is as follows:

var year=this.date.getFullYear();

Get the month, here is the month index so 1

Copy code The code is as follows:

var month=this.date.getMonth() 1;

Get the date of the day

Copy code The code is as follows:

var day=this.date.getDate();

Get the day of the week and return 0. Sunday 1. Monday 2. Tuesday 3. Wednesday 4. Thursday 5. Friday 6. Saturday

Copy code The code is as follows:

var week=this.date.getDay();

Get the day of the week the first of the month is

Copy code The code is as follows:

      var getWeekDay=function(year,month,day){
            var date=new Date(year,month,day);
               return date.getDay();
           }
 var weekstart= getWeekDay(this.year, this.month-1, 1)

Get the number of days in the current month

Copy code The code is as follows:

          var getMonthDays=function(year,month){
            var date=new Date(year,month,0);
                return date.getDate();
}
        var   monthdays= this.getMonthDays(this.year,this.month);

                                                                                                                                                                                The following are actually some operations and judgments about the date corresponding to the day of the week, and dynamic splicing tags. I will directly send the example I wrote:

Copy code The code is as follows:

   


   
   
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template