Get first 3 Letters of a Month's Name in JavaScript

avatar

Borislav Hadzhiev

Mon Oct 25 20211 min read

banner

Photo by Tommy Tang

Get the first 3 Letters of a Month's Name #

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.

index.js
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:

  1. the locale - in which language the name of the month should be returned. You could set it to default, to use the user's browser preferences.
  2. the options object - we set the 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.

index.js
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

Further Reading #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee