Borislav Hadzhiev
Mon Oct 25 2021·1 min read
Photo by Tommy Tang
Use the toLocaleString()
method to get the first 3 letters of a month's
name. The method accepts an options object, where if the month
property is set
to short
, the return value is the first 3 letters of the month's name.
const date = new Date(2025, 03, 16); const shortName = date.toLocaleString('en-US', {month: 'short'}); console.log(shortName); // 👉️ Apr const narrowName = date.toLocaleString('en-US', {month: 'narrow'}); console.log(narrowName); // 👉️ A const longName = date.toLocaleString('en-US', {month: 'long'}); console.log(longName); // 👉️ April
We used the toLocaleString method to get the first 3 letters of a month's name.
We passed the following parameters to the method:
default
, to use the user's browser preferences.month
setting to short
to get the
first 3 letters of the month's name. Other possible values are narrow
and
long
.If you want to change the language of the months name update the locale parameter. Here's an example using german locale.
const date = new Date(2025, 9, 16); const shortName = date.toLocaleString('de-DE', {month: 'short'}); console.log(shortName); // 👉️ Okt const narrowName = date.toLocaleString('de-DE', {month: 'narrow'}); console.log(narrowName); // 👉️ O const longName = date.toLocaleString('de-DE', {month: 'long'}); console.log(longName); // 👉️ Oktober