T
T
temaszver2020-05-20 18:13:45
JavaScript
temaszver, 2020-05-20 18:13:45

How to add months to the current date?

so that it is correct with any date

source data: 05/20/2020

output: +13 months for example
06/20/2022
UPDATE
https://jsfiddle.net/1kL9jt68/2/

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2020-05-20
@temaszver

date.setMonth( date.getMonth() + 13 )
https://ideone.com/gLBNz4

A
Alexander Miranovich, 2020-05-20
@aleks_664

var date = new Date(1999,11,31);
  date.setMonth(D.getMonth() + 3);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question