How to get the previous month name in JavaScript

1 Answer

0 votes
const d = new Date();

d.setMonth(d.getMonth()-1);

const previousMonth = d.toLocaleString('en-us', { month: 'long' });   

console.log(previousMonth); 




/*
run:

January

*/

 



answered Feb 11, 2021 by avibootz

Related questions

1 answer 137 views
1 answer 136 views
1 answer 136 views
2 answers 162 views
1 answer 143 views
...