JavaScript getMonth()

getMonth() returns the month of a JavaScript Date in local time as a number from 0 to 11. January is 0 and December is 11.

const date = new Date(2026, 8, 10);
console.log(date.getMonth()); // 8 = September

If you need a human month number from 1 to 12, add 1. If you need a month name, locale formatting is usually better.

getMonth() Syntax Top ↑

const monthIndex = date.getMonth();

Convert getMonth() to 1–12 Top ↑

const monthNumber = date.getMonth() + 1;
const padded = String(monthNumber).padStart(2, "0");

Convert getMonth() to a Month Name Top ↑

const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
console.log(months[date.getMonth()]);

Locale-Aware Month Formatting Top ↑

const monthName = date.toLocaleDateString("en-US", { month: "long" });

getMonth() vs getUTCMonth() Top ↑

const localMonth = date.getMonth();
const utcMonth = date.getUTCMonth();

Common getMonth() Mistakes Top ↑

  • Displaying the zero-based value directly to users.
  • Passing 12 to a numeric Date constructor expecting December; 11 is December.
  • Using a manual English month array when the UI should respect user locale.

See alert examples from the original learning path. getFullYear() Date Reference




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer