I have a piece of code to find the next month of the given date.
var d = new Date('2018-03-31');
dt = new Date(d.setMonth(d.getMonth() + 1));
document.getElementById("demo").innerHTML = dt;
But i'm wondering what is wrong here since it adds one month to March
& gives May
instead of April
?
DEMO:
var d = new Date('2018-03-31');
dt = new Date(d.setMonth(d.getMonth() + 1));
document.getElementById("demo").innerHTML = dt;
<p id="demo"></p>