Announcement: Launch of Powerful Code Scripts to Simplify Development
October 10, 2025
This article will teach you how to use a JavaScript date object to change a month's number into a name.
The month name is returned in string format by the function below, which accepts the month number as an argument.
function getMonthName(month){
const d = new Date();
d.setMonth(month-1);
const monthName = d.toLocaleString("default", {month: "long"});
return monthName;
}
getMonthName(11)
Output:
November
Some Explanations: