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

172
Vistas
Change date format of moment(obj.created_at).toDate()

I need to change format from 2022-12-30 to 30-12-2022 (DD/MM/YYYY)

But I need to keep it as DATE object, not as string

Here what I've tried:

obj.created_at                                        // return string 2022-12-30 (YYYY-MM-DD)
new Date(obj.created_at)                              // return date 12/30/2022 (MM/DD/YYYY)
new Date(obj.created_at).toLocaleDateString('id-ID')  // return string 30/12/2022 (DD/MM/YYYY), this is the correct format, but it's a string not a date
moment(obj.created_at).toDate()                       // return date 12/30/2022 (MM/DD/YYYY)
moment(obj.created_at).format('DD/MM/YYYY')           // return string 30/12/2022 (DD/MM/YYYY), this is the correct format, but it's a string not a date
moment(obj.created_at, 'YYYY-MM-DD').toDate()         // return date 12/30/2022 (MM/DD/YYYY)

Thank you :)

about 4 years ago · Juan Pablo Isaza
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