I. Time addition and subtraction, date addition and subtraction, the same as year, month, and day addition and subtraction. VarmydatenewDate (& amp; #39; 2012-05-10:10:21 & amp; #39;); mydate. setDate (mydate. getDate () + 50); // The current time plus 50 days and two days. Plus or minus minutes, setMinutes method format conversion Date. p...
I. Time addition and subtraction, date addition and subtraction, the same as year, month, and day addition and subtraction.
Var mydate = new Date ('2017-05-10 10:10:21 ');
Mydate. setDate (mydate. getDate () + 50); // Add 50 days to the current time
II. Plus or minus minutes, setMinutes Method
Format Conversion
Date. prototype. format = function (format)
{
Var o = {
"M +": this. getMonth () + 1, // month
"D +": this. getDate (), // day
"H +": this. getHours (), // hour
"M +": this. getMinutes (), // minute
"S +": this. getSeconds (), // second
"Q +": Math. floor (this. getMonth () + 3)/3), // quarter
"S": this. getMilliseconds () // millisecond
}
If (/(y +)/. test (format ))
Format = format. replace (RegExp. $1, (this. getFullYear () + ""). substr (4-RegExp. $1. length ));
For (var k in o)
If (new RegExp ("(" + k + ")"). test (format ))
Format = format. replace (RegExp. $1, RegExp. $1. length = 1? O [k]: ("00" + o [k]). substr ("" + o [k]). length ));
Return format;
}
Var mydate = new Date ('2017-05-10 10:10:21 ');
Mydate. setDate (mydate. getDate () + 50 );
Mydate. setMinutes (min, sec, MS)
Alert (mydate. format ("yyyy-MM-dd hh: mm: ss "));
From mixer-