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

226
Vistas
How can I get the difference in the two dates in js which are in string?

I have a certain format which is in the

{
    "updatedAt": "2022-01-04 22:41:32.268897",
    "status": "open",
    "createdAt": "2022-01-04 22:41:26.328339"
}

I want to get the difference in hours or minutes of both the dates I tried many but didn't get the expected result.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use the Date module in javascript.

const obj = { "updatedAt": "2022-01-04 22:41:32.268897", "status": "open", "createdAt": "2022-01-03 22:41:26.328339" };

const updatedAt = new Date(obj.updatedAt);
const createdAt = new Date(obj.createdAt);

const diffInMilliSecs = updatedAt - createdAt;

This difference is in milliseconds. You can now convert this into seconds or minutes or hours.

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