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 129 views
1 answer 131 views
1 answer 132 views
2 answers 159 views
1 answer 140 views
...