How to add months to a date ?
Posted: Fri Dec 23, 2022 12:28 am
Hello,
I would like to add month to a date. I have got 2 dates in my edit form, the today's date and another date which should be 1 month after the date of the first chosen date. I know how to add days but I cannot find out how to add month.
I have tried that piece of code
It seems that addMonths() doesn't exist in Javascript. I have maybe to add months by using getMonth() and setMonth() but I haven't found yet. Anyone did that already ?
Many thanks
Yves
I would like to add month to a date. I have got 2 dates in my edit form, the today's date and another date which should be 1 month after the date of the first chosen date. I know how to add days but I cannot find out how to add month.
I have tried that piece of code
Code: Select all
function AddMonthsToDateObject(i, months) {
let 0 = $('#' + i);
let d = nuFORM.removeFormatting(o.val(), o.attr('data-nu-format'));
nuSetDateValue(i ,new Date(d).addMonths(months));
}
Many thanks
Yves