Moment.js not respecting language

Hey everyone,

I’ve been using Moment.js to format dates in Spanish, but I’ve noticed it’s not working as expected anymore. Previously, the language translation worked fine, but now it shows up in English instead.

Here’s what’s happening:

This is the code I’m using:
**Hoy, {{ moment().locale('es-mx').format('dddd DD [de] MMMM [de] y') }}**

It currently displays: Hoy, Thursday 12 de September de 2024
But it should display: Hoy, Jueves 12 de Septiembre de 2024

Any insights on what might be causing this? Thanks in advance!

Thank you.

Hello @Adorp

I understand your issue , If you want to format a date in Spanish using Moment.js :
moment().locale('es').format('dddd DD [de] MMMM [de] YYYY')

2 Likes

Hi @Adorp ,

To achieve this, you'll need to install the Moment.js locale first. You can do this by adding it as a new library under the app settings.

Here are various CDN libraries available for Moment.js. In my case, I used the following, and it worked: https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment-with-locales.min.js

Screenshot 2024-09-17 at 11.05.04 AM

**Hoy, {{ moment().locale('es').format('dddd DD [de] MMMM [de] YYYY') }}**

Hope this helps! Let me know if you need more details.

2 Likes