Recently looked at the JS date of some functions, suddenly thought of the calendar control, so try to write a, as a background programmer I have a limited level, we hold the attitude of learning to see me write this example bar, learning progress together!
First, a commonly used date function:
Date (Year,month,day)
var date=new date ();
Get year
var year=this.date.getfullyear ();
Get the month, this is the monthly index so it takes +1
var month=this.date.getmonth () +1;
Get the date of the day
var day=this.date.getdate ();
Gets the day of the week and returns 0. Sunday 1 weeks 12 weeks 23 weeks 34 weeks 45 weeks 56. Saturday
var week=this.date.getday ();
get the month number one is the week
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 of the month
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 use the parameters on so much, the back is actually about the date of the week some of the operation and judgment, dynamic splicing label, the following directly to my example sent out:
Effect Chart:
The
Code has been changed again to change the view table to Div, which is to solve the tableinnerhtml of IE's read-only problem. Additional options are added for the purpose of being configurable.
The above code has a simple description, function is the most basic, if more in-depth do can be extended, I hope this article can give you some inspiration.