JS get current date time and other actions
var mydate = new Date ();
Mydate.getyear (); Get Current year (2-bit)
Mydate.getfullyear (); Get full year (4-bit, 1970-????)
Mydate.getmonth (); Get Current month (0-11, 0 for January)
Mydate.getdate (); Get the current day (1-31)
Mydate.getday (); Get Current week x (0-6, 0 for Sunday)
Mydate.gettime (); Gets the current time (number of milliseconds since 1970.1.1)
Mydate.gethours (); Get the current number of hours (0-23)
Mydate.getminutes (); Get the current number of minutes (0-59)
Mydate.getseconds (); Get the current number of seconds (0-59)
Mydate.getmilliseconds (); Get current number of milliseconds (0-999)
Mydate.tolocaledatestring (); Get Current date
var mytime=mydate.tolocaletimestring (); Get current time
Mydate.tolocalestring (); Get Date and time
Date Time Script Library method list
Date.prototype.isLeapYear Judge Leap Year
Date.prototype.Format Date format
DATE.PROTOTYPE.DATEADD Date Calculation
Date.prototype.DateDiff Comparison Date Difference
Date.prototype.toString Date-turn string
Date.prototype.toArray date split into arrays
Date.prototype.DatePart some information about the date
Date.prototype.MaxDayOfDate the maximum number of days of the month from which the date is taken
Date.prototype.WeekNumOfYear the first weeks of the year in which the date is judged
Stringtodate String Turn Date type
Isvaliddate Validation Date Validity
Checkdatetime Full Date Time check
Daysbetween Date Days Bad
JavaScript-common function libraries with prototype extensions1 * *
2 * Retrieve array elements (prototype extension or overload)
3 * @param The value of the element retrieved by {o}
4 * @type int
5 * @returns Element index
6 */
7 Array.prototype.contains = function (o) {
8 var index =-1;
9 for (var i = 0, i < this. Length;i + +) {if (this [i] = = O) {index = i; break;}}
Ten return index;
11}
12
13 * *
14 * Date format (prototype extension or overload)
15 * Format Yyyy/yyyy/yy/yy represents year
* mm/m Month
* W/W Week
* dd/dd/d/d Date
* hh/hh/h/h Time
* mm/m minutes
* SS/SS/S/S seconds
* @param {FORMATSTR} format template
* @type String
* @returns Date string
25 */
num Date.prototype.format = function (formatstr) {
var str = FORMATSTR;
var Week = [' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' six '];
str = str.replace (/yyyy| YYYY/, this. getFullYear ());
str = str.replace (/yy| YY/, (this. getyear ()%) > 9? (this. getyear ()%). ToString (): ' 0 ' + (this. getyear ()% 100));
str = str.replace (/MM/, (this. getmonth () + 1) > 9? (this. getmonth () + 1). To