function getMonthName(monthNumber) {
const date = new Date();
date.setMonth(monthNumber - 1);
return date.toLocaleString([], { month: 'long' });
}
Post funny things about programming here! (Or just rant about your favourite programming language.)
The legacy
Date
object has many problems and this is one of them. Another infamous one is that it uses zero-based month numbers: January is the zeroth month and December the 11th month.This will be fixed Any Day Now™️ when Temporal is released. This is a carefully designed library that supersedes
Date
and is currently waiting on some standards to be finalized.