Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript increment date by month wise from given date

i am trying to make program . in which i have a text box with value of 2013-08-27 i want to increase this date by month wise up to 30 months

ex:-
2013-08-27
2013-09-27 
2013-10-27
2013-11-27
2013-12-27
2014-01-27
2014-02-27

.........
2015-01-27

i already googled this topic ... but i am not getting any clue how to do it.. as for i get to this code

var myDate = new Date();

//add a day to the date
myDate.setDate(myDate.getDate() + 1);

but this is giving me reslut as 11,17 i want to increase year also by month wise up to 30 months from given date please give me any clue ... sorry for bad English

like image 862
Allex Avatar asked Aug 01 '26 11:08

Allex


1 Answers

Try this:

var myDate = new Date();

for(var i =0;i<30; i++)
{
   myDate.setMonth(myDate.getMonth() + 1);
   console.log(myDate);

}
like image 175
Mr.G Avatar answered Aug 03 '26 02:08

Mr.G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!