Subtract Months from a Date in JavaScript

 

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);

Tags:

Share:

Related posts