I think I'm missing something about this, I'm trying to add the current date of 7 days I'm 14, then 21. Whatever I end up is cycling the interval instead of the current date + 7, the current date 14+.
var date = new date (); (Var i = 0; i & lt; 4; i ++) for {var tempDate = date; Var Rikutton = Tempdate. Date (date. GateDet) + (i * 7)); Var repeats = new date (repoton); Console.log (repeats); }
Results in:
"2015-03-17T21: 03: 13.326Z" "2015-03-24T21: 03: 13.326Z" 2015-04-07T20: 03: 13.326Z "" 2015-04-28 T 20: 03: 13.326Z "
Instead of the desired, 24, 31 th & amp; 8th
var tempDate = date;
from a reference to date
. Similarly, setDate
does not return a new date, it changes the date.
A solution must be made a copy:
var tempDate = new date (date);
Your loop can be simplified
var repeats = (new date (date)). Set date (date.getDate () + (i * 7))
No comments:
Post a Comment