The title is a bit around, in fact, it means that according to the current time of the system, get n minutes or n hours or n months after the time.
For example: Under current time, get 10 minutes after the time.
var date=new date (); 1. JS gets the current time Var min=date.getminutes (); 2. Gets the current minute date.setminutes (min+10); 3. Set current time + 10 minutes: Reset the value after the current number of minutes to the number of minutes of the date object var y = date.getfullyear (), var m = (Date.getmonth () + 1) < 10? ("0" + (date.getmonth () + 1)): (Date.getmonth () + 1); var d = date.getdate () < 10? ("0" + date.getdate ()): Date.getdate (); var h = date.gethours () < 10? (' 0 ' + date.gethours ()): Date.gethours () var f = date.getminutes () < 10? (' 0 ' + date.getminutes ()): Date.getminutes () var s = date.getseconds () < 10? (' 0 ' + date.getseconds ()): Date.getseconds () var formatdate = y+ '-' +m+ '-' +d + ' "+ H +": "+ F +": "+ s;console.log (Form atdate)//Get 10 minutes after the time, formatted as YYYY-MM-DD h:f:s
Similarly, set 30 minutes, 60 minutes or 1 hours, 5 hours, you can convert the hour to minutes, and then get the current minute plus the time you need to set.
Get the date after 1 months:
var date=new date ();d Ate.setmonth (Date.getmonth () +1), var y = date.getfullyear (), var m = (Date.getmonth () + 1) < 10? ("0" + (date.getmonth () + 1)): (Date.getmonth () + 1); var d = date.getdate () < 10? ("0" + date.getdate ()): Date.getdate (); var h = date.gethours () < 10? (' 0 ' + date.gethours ()): Date.gethours () var f = date.getminutes () < 10? (' 0 ' + date.getminutes ()): Date.getminutes () var s = date.getseconds () < 10? (' 0 ' + date.getseconds ()): Date.getseconds () var formatwdate = y+ '-' +m+ '-' +d + ' "+ H +": "+ F +": "+ S; Console.log (' formatwdate ', formatwdate)
Similarly get n months or n months before the date is so
JS gets n minutes (or n hours or n months) after (or before) the time (date)