js get current 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()];
Example 2: javascript getmonth
new Date().getMonth();
Example 3: 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 4: get current month of year in number javascript
var today = new Date();
var month = today.getMonth();
console.log(month);