date - Javascript getMonth returning previous month after adding days -


this question has answer here:

i adding days in today date , getting timestamps in milliseconds.

  for(i=1;i<=shippingdays;i++){        var result = new date();       result.settime( result.gettime() + * 86400000 );       console.log(result);       console.log(result.getmonth()+'-'+result.getdate()+'-'+result.getfullyear());       newdate = new date(result.getmonth()+'-'+result.getdate()+'-'+result.getfullyear());      console.log(newdate);  };  

the first console returns thu apr 07 2016 18:34:33 gmt+0500 (pkt) later on result.getmonth() returns previous month value. second console returns 3-7-2016 , third console returns mon mar 07 2016 00:00:00 gmt+0500 (pkt).

my ultimate goal milliseconds of next days 00:00:00. today 04-06-2016. want milliseconds timestamp of next few days. , time stamp should calculated start of date, i.e, 00:00:00

can body let me know doing wrong?

months data.getmonth zero based (so january 0, feb 1, etc).

so if want use month value make new date add one.


Comments