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.
const monthIndex = date.getMonth();
const monthNumber = date.getMonth() + 1;
const padded = String(monthNumber).padStart(2, "0");
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
console.log(months[date.getMonth()]);
const monthName = date.toLocaleDateString("en-US", { month: "long" });
const localMonth = date.getMonth();
const utcMonth = date.getUTCMonth();
See alert examples from the original learning path. getFullYear() Date Reference
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.