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 216 views
1 answer 219 views
1 answer 221 views
2 answers 267 views
1 answer 222 views
...