Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
I'm trying to convert an ISO date from an API to alphabetical months, how can you do it?

I'm trying to convert the following date I'm getting from the API:

2022-04-01T05:09:09.403Z

To the next one:

July 19, 2021

But I don't know how to do it. I've tried this so far:

  const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

for (var i = 0; i < postsResults.length; i++) {
  const trimmedData = postsResults[i].last_posted_at
  const finalData = trimmedData.substring(0, 10);
  let monthDate = finalData.slice(5,7)
  if (monthDate.includes(0)) {
    monthDate = finalData.slice(6,7)
  } else {
    monthDate = finalData.slice(5,7)
  }
  result = months[monthDate]
}

Postsresults is the array that I'm fetching. I'm slicing certain characters until I get the exact letters to match the months. This doesn't work as it always returns April.

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda