1, get JavaScript time using the built-in date function to complete
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
2, 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
3, Time calculation and format
(1) time plus a fixed value
var d = new Date ();
D.setmonth (D.getmonth () + 1);
/** Plus one months, the same, you can add a day: GetDate () +1, plus one year: getyear () +1, plus one hour: getHours () +1, plus one minute: getminutes () +1, plus one second: getseconds () + 1, plus one millisecond: getmilliseconds () +1. * *
Console.log (D.format ("Yyyy-mm-dd HH:mm:ss"));
(2) Time added minus
var D1 = new Date ();
var d2 = new Date ();
D1.setseconds (D.getseconds () + 1);
Time = parseint (D1-D2);//After addition minus is a string (in milliseconds), with parseint () can be converted to digital
D.setmonth (D.getmonth () + 1);
Console.log (D.format ("Yyyy-mm-dd HH:mm:ss")),//format () can format the time, note that the month m and H are uppercase, and if you format the time month in other ways, add 1
4. Electronic Watch