I would like to set the month
and date
of next month from the date of subscription.
Example: If today is 30th January
, then the next date of subscription should change to the 30 days after 30th Jan
means if the month is not leap then it should set to 2nd March
instead of 30th Feb
.
Along with this also when the month is December
, the month should set to Jan.
This is the code I have thought to use which is solving my Dec to Jan
problem but I am still unsure about the February
thing.
var now = new Date();
if (now.getMonth() == 11) {
var current = new Date(now.getFullYear() + 1, 0, now.getDate());
} else {
var current = new Date(now.getFullYear(), now.getMonth() + 1, now.getDate());
}