how to get month in javascript code example

Example 1: javascript getmonth

new Date().getMonth(); //note that Jan=0, Dec=11 (annoying I know)

Example 2: 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 3: how to get only month and year in js

let dateObj = new Date();

let myDate = (dateObj.getUTCFullYear()) + "/" + (dateObj.getMonth() + 1)+ "/" + (dateObj.getUTCDate());