date - Days are not added properly with momentJS in JavaScript -


i have code want next 15 days start date

    var fortnightstart = moment("15 04 2015", "dd mm yyyy");      (var = 1; <= 15; i++) {          dates.push(fortnightstart.add(i, "days").format("d mmm"));      }      console.log(dates); 

this output

["16 apr", "18 apr", "21 apr", "25 apr", "30 apr", "6 may", "13 may", "21 may", "30 may", "9 jun", "20 jun", "2 jul", "15 jul", "29 jul", "13 aug"] 

i don't know why missing few days.

on every iteration add i days initial date - keeps accumulating (+1, +2, +3 etc). need add not i 1 fortnightstart.

var fortnightstart = moment("15 04 2015", "dd mm yyyy"); (var = 1; <= 15; i++) {     // 1, not     dates.push(fortnightstart.add(1, "days").format("d mmm")); } console.log(dates); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -