Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
Momentjs is not converting certain Spanish months to UTC

I am working on a React Native application which is available on two languages (English & Spanish). Getting date in English is fine but for Spanish, Momentjs is not able to convert it to moment object for certain months(in spanish) like Abril, It throws Invalid date as output, while other month like Septiembre is working fine and it is getting converted to moment object.

const aprilDateES = moment("09 Abril, 2021") // Invalid date
const septeDateEs = moment("09 Septiembre, 2021") // Thu Sep 09 2021 00:00:00 GMT+0530

It is also throwing warning for Abril month - Warning message

My goal is to convert all Spanish date/month to moment object so that it can be converted to other format like DD/MM/YYYY and can also be validated using momentJS.

Here's the link to playground - https://replit.com/@DevAk1/MomentJSSpanishDate#src/App.jsx

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Change import to -

import moment from 'moment/min/moment-with-locales'

Then use this -

const date = moment('09 Abril, 2021', 'DD MMMM, YYYY', 'es').locale('en') 
// Fri Apr 09 2021 00:00:00 GMT+0530

Note - This is specific to format and language. Please change the source/target language and the date format according to the requirement.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda