To subtract weeks from a date:
To subtract any number of weeks from JavaScript date object. first create a JavaScript date object (you can pass also desired date in date object) then only subtract you need to subtract number of days from date object
currentdate = new Date();
totalWeeksToSubtract = 2
currentdate.setDate(currentdate.getDate() - totalWeeksToSubtract * 7);
To use calculate date difference between two dates in months the following code may help you
var currentdate = new Date();
var oldDate = new Date('2022-02-17'));
let monthsDiff;
monthsDiff = (currentdate.getFullYear() - oldDate.getFullYear()) * 12;
monthsDiff -= oldDate.getMonth();
monthsDiff += currentdate.getMonth();
console.log(months)