This article mainly introduces how to use the jsCalender control. If you need it, you can refer to the projects that have been catching up recently. The project is now in a stable state, but it is only for repair, modification, and modification. I am a backend programmer. I have to write everything from the web to the mobile interface... These two days I finally got idle. I had nothing to do with reading some functions about js date and suddenly thought of the calendar control. So I tried to write one. As a background programmer, I am at a limited level, let's take a look at the example I wrote...
First, a common Date function: Date (year, month, day)
The Code is as follows:
Var date = new Date ();
Get year
The Code is as follows:
Var year = this. date. getFullYear ();
Obtain the month. Here is the monthly index, so we need to add 1 more.
The Code is as follows:
Var month = this. date. getMonth () + 1;
Obtain the number of the current day
The Code is as follows:
Var day = this. date. getDate ();
Returns the day of the week. 0. Sunday 1. Monday 2. Tuesday 3. Wednesday 4. Thursday 5. Friday 6. Saturday.
The Code is as follows:
Var week = this. date. getDay ();
Obtain the number 1 of the week in the current month.
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)
Obtain the number of days in the current month
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 );
Well, we have used so many parameters. The following are some operations and judgments on the day of the week corresponding to the date, and dynamic tag splicing. The example I wrote is directly sent below:
The Code is as follows: