Today its 28 jul Thursday 2022,
i want to get the 6 last months before to july
i want to get the 12 las months before to july
i was trying like this for 6 month
var d = new Date();
const month= d.setDate(d.getDate() - 180).getMonth()
console.log(month)
i need in text, jun, may and so on
CodePudding user response:
you can use moment().subtract()
. https://momentjs.com/
CodePudding user response:
There is a package for the calendar Go Here
moment().add(10, 'days').calendar(); // use this to add days, months or year in add parameter.
CodePudding user response:
You can use setMonth and then toLocaleString to get the month name in text.
var d = new Date();
d.setMonth(d.getMonth() - 6)
console.log(d.toLocaleString('default', {month: 'short'}))