javascript getmonth gives previous month code example
Example 1: Javascript get month name
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var d = new Date();
var monthName=months[d.getMonth()]; // "July" (or current month)
Example 2: get current month of year in number javascript
var today = new Date();
var month = today.getMonth(); // Returns 9
console.log(month); // Output: 9