Use JavaScript built-in method to subtract from a date you can also pass your desired date in date object
const date = new Date(); let months = 4 date.setMonth(date.getMonth() - months);
Copyright © 2024 datapearls.org