js get month of date code example
Example 1: current month in javascript
// Find current month in JavaScript
const localDate = new Date();
const months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];
let currentMonth = months[localDate.getMonth()];
console.log(currentMonth);
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