Cannot get local month name

I’m developing a site in the Croatian language so I’d like to have localized names of the month. I’m using 11ty static site generator where I’m handling the publishedDate value using this javascript code:

var dobj = new Date(dateObj);
var day = dobj.getDate();
var year = dobj.getFullYear();
var month = dobj.toLocaleString('hr-HR', { month: 'long' });
return day + ". " + month + " " + year + ".";

As HTML goes, I have <html lang="hr"> tag on each page and my computer is using elementaryOS Linux with Croatian locale installed.

Now, everything works fine in my local environment, but when I push it to Netlify, I’m always getting English versions of month names.

Thank you for your time and effort.


Localised month names can be obtained like this:

console.log(new Intl.DateTimeFormat('hr-HR', {month: 'long'}).format(new Date()));

You can get entire date using:

/* var options = 'check available formatting options here:' */
console.log(new Intl.DateTimeFormat('hr-HR', options).format(new Date()));
1 Like

Thank you @hrishikesh for your kind and prompt help, but it doesn’t work, still having English month names.

Do you have a test website or repo where someone can check this? I ran the code on my website and I did different month names.

Thank you @hrishikesh for this help.

The WiP site is at but the repo is private for this project so I’m not comfortable sharing it.
However, it’s quite simple:

  • The site is built using 11ty SSG + Nunjucks
  • The data is coming from GraphCMS
  • The custom nunjucks fiter has this code:
config.addFilter("datumObjave", dateObj => {
        var dobj = new Date(dateObj);
        var day = dobj.getDate();
        var year = dobj.getFullYear();
        var month = new Intl.DateTimeFormat('hr-HR', { month: 'long' }).format(new Date(dateObj));
        return day + ". " + month + " " + year + ".";

where dateObj has ISO8601 form.

Once again, everything works fine locally and Netlify build produces no errors, but always present english month name.


That’s really strange. Here’s the output I get in my console. It’s correct according to the 2 languages I know, so, I’m assuming it’s correct in the HR one too.:

Since JavaScript is client-side, there’s a very little chance that there’s something going wrong on Netlify side, as I am getting the same result in my local test as well as on the deployed version.

A minimum reproducible repo would help too, something that would just output the date using your code or you might wait for someone better to assist you with this.

Yes, you’re right, it’s correct name for December in Croatian language.
Anyway, thank you again for your time and effort, I’ll keep digging.


Problem solved with updating Node.js in my build environment from v12.something to v14.15.0.