Copy("0" + this.getDate()).slice(-2)

for the date, and similar:

Copy("0" + (this.getMonth() + 1)).slice(-2)

for the month.

Answer from Hugo on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getMonth
Date.prototype.getMonth() - JavaScript | MDN
The getMonth() method of Date instances returns the month for this date according to local time, as a zero-based value (where zero indicates the first month of the year).
🌐
W3Schools
w3schools.com › jsref › jsref_getmonth.asp
JavaScript Date getMonth() Method
❮ Previous JavaScript Date Reference Next ❯ · Get the month: const d = new Date(); let month = d.getMonth(); Try it Yourself » ·
Discussions

How do I get Month and Date of JavaScript in 2 digit format? - Stack Overflow
Note that getMonth returns a number between 0 and 11, not 1 and 12. More on stackoverflow.com
🌐 stackoverflow.com
date - why does javascript getMonth count from 0 and getDate count from 1? - Stack Overflow
This question is purely to satisfy my curiosity. In the JavaScript Date object, when you call getMonth() it returns the month but it counts from 0. 0 = January 1 = February ... But when you call More on stackoverflow.com
🌐 stackoverflow.com
javascript - Get month name from Date - Stack Overflow
5 Javascript: How to get the month name of the current date without setting an array of month names? -1 convert the .getMonth to string month in javaScript(convert 0 to jan) More on stackoverflow.com
🌐 stackoverflow.com
I just found that Javascript's built in Date.getMonth() method is zero indexed, meaning it returns "0" for January, "1", for February, etc.
It's so you can index into a months array for easy localization. The design makes sense from that perspective... Still not great, but it's not like someone took a fat draw on a joint and asked what would happen if we had a zeroth month. More on reddit.com
🌐 r/learnprogramming
11
0
March 16, 2020
🌐
Greenroots
blog.greenroots.info › the-best-way-to-get-the-month-name-from-a-date-in-javascript
The best way to get the month name from a date in JavaScript
January 6, 2025 - This short article will teach you how to get the month name from a date in the most straightforward way with a few added advantages. JavaScript Date object provides a method called getMonth() to return you the information of the month part in a date.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
Date.prototype.getMonth() Returns the month (0 – 11) in the specified date according to local time. Date.prototype.getSeconds() Returns the seconds (0 – 59) in the specified date according to local time. Date.prototype.getTime() Returns the numeric value of the specified date as the number ...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-date-getmonth-method
JavaScript Date getMonth() Method - GeeksforGeeks
July 11, 2025 - The date.getMonth() method is used to fetch the month(0 to 11) from the given Date object (0 represents the first month of the year). ... This function does not accept any parameter.
Top answer
1 of 16
1572

It is now possible to do this with the ECMAScript Internationalization API:

Copyconst date = new Date(2009, 10, 10);  // 2009-11-10
const month = date.toLocaleString('default', { month: 'long' });
console.log(month);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

'long' uses the full name of the month, 'short' for the short name, and 'narrow' for a more minimal version, such as the first letter in alphabetical languages.

You can change the locale from browser's 'default' to any that you please (e.g. 'en-us'), and it will use the right name for that language/country.

With toLocaleStringapi you have to pass in the locale and options each time. If you are going do use the same locale info and formatting options on multiple different dates, you can use Intl.DateTimeFormat instead:

Copyconst formatter = new Intl.DateTimeFormat('fr', { month: 'short' });
const month1 = formatter.format(new Date());
const month2 = formatter.format(new Date(2003, 5, 12));
console.log(`${month1} and ${month2}`); // current month in French and "juin".
Run code snippetEdit code snippet Hide Results Copy to answer Expand

For more information see my blog post on the Internationalization API.

2 of 16
1482

Shorter version:

Copyconst monthNames = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"
];

const d = new Date();
document.write("The current month is " + monthNames[d.getMonth()]);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Note (2019-03-08) - This answer by me which I originally wrote in 2009 is outdated. See David Storey's answer for a better solution.

🌐
TutorialsPoint
tutorialspoint.com › javascript › date_getmonth.htm
JavaScript Date getMonth() Method
<html> <body> <script> function getMonthName(date) { const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; return months[date.getMonth()]; } const currentDate ...
🌐
CoreUI
coreui.io › answers › how-to-get-the-current-month-in-javascript
How to get the current month in JavaScript · CoreUI
October 2, 2025 - Get the current month in JavaScript using getMonth() method which returns 0-11, or getMonth() + 1 for standard month numbers 1-12.
🌐
Codecademy
codecademy.com › docs › javascript › dates › .getmonth()
JavaScript | Dates | .getMonth() | Codecademy
June 5, 2023 - The example below defines a new Date object dateTimeNow, an array months containing the names of the calendar months, and stores the result of the getMonth() method in a new variable month. Finally, the current date\time, the current month, and the months remaining in the current year are logged to the console. ... Front-end engineers work closely with designers to make websites beautiful, functional, and fast. ... Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
🌐
HCL Software
help.hcl-software.com › dom_designer › 9.0.1 › reference › r_wpdr_standard_date_getmonth_r.html
getMonth (JavaScript)
Date (Standard - JavaScript) getMonth() : int · This computed label adds one year to the current date. One day is first subtracted if the date is February 29 (leap year) so it appears as February 28 instead of March 1 in the next year.
🌐
Educative
educative.io › answers › what-is-getmonth-in-javascript
What is getMonth() in JavaScript?
The getMonth() method in JavaScript returns the month for the specified date according to the local time.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getUTCMonth
Date.prototype.getUTCMonth() - JavaScript | MDN
July 10, 2025 - The getUTCMonth() method of Date instances returns the month for this date according to universal time, as a zero-based value (where zero indicates the first month of the year).
🌐
W3Schools
w3schools.com › js › js_date_methods.asp
JavaScript Date Methods
Old JavaScript code might use the non-standard method getYear(). ... The getMonth() method returns the month of a date as a number (0-11).
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-month-and-date-of-javascript-in-two-digit-format
How to get Month and Date of JavaScript in two digit format ? - GeeksforGeeks
July 11, 2025 - JavaScript · const currentDate = new Date(); const month = (currentDate.getMonth() + 1).toLocaleString('en-US', { minimumIntegerDigits: 2, useGrouping: false }); const day = currentDate.getDate().toLocaleString('en-US', { minimumIntegerDigits: 2, useGrouping: false }); console.log(`Current Date: ${month}/${day}`); Output ·