javascript - JS setDate() in loop -


i want call function each day within next 2 weeks , pass parameters such day , month. use method: startdate.setdate(startdate.getdate() + 1) found here gets messy after first 6 steps of loop

var date = new date,     searchdate = new date,     period = 14;  for(i = 1; <= period; i++){     searchdate.setdate(date.getdate() + i);     // somefunction(searchdate.getdate(), searchdate.getmonth()); } 

what console.log(i + ": " + searchdate) returns:

1: tue aug 27 2013 17:38:04 gmt+0200 2: wed aug 28 2013 17:38:04 gmt+0200 3: thu aug 29 2013 17:38:04 gmt+0200 4: fri aug 30 2013 17:38:04 gmt+0200 5: sat aug 31 2013 17:38:04 gmt+0200 6: sun sep 01 2013 17:38:04 gmt+0200 // far 7: thu oct 03 2013 17:38:04 gmt+0200 // , after week it's october 8: sun nov 03 2013 17:38:04 gmt+0100 9: thu dec 05 2013 17:38:04 gmt+0100 10: sun jan 05 2014 17:38:04 gmt+0100 11: thu feb 06 2014 17:38:04 gmt+0100 12: mon mar 10 2014 17:38:04 gmt+0100 13: tue apr 08 2014 17:38:04 gmt+0200 14: sat may 10 2014 17:38:04 gmt+0200 

any clue on this?

what want :

searchdate.settime(date.gettime() + (24 * 3600 * 1000 * i)); 

it adds time internal value (timestamp) of date instead of adding day.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -