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

225
Vistas
How to get difference between two datetime of moment.js?

How can I calculate the difference between two dates time in moment.js?

moment.duration((moment(startDate).format("MM-DD-YYYY h:mm:ss a")).diff(moment(new Date()).format("MM-DD-YYYY h:mm:ss a")));

and My startDate = 2022-02-02T12:12:25Z
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I found the solution ,may help other people :

var now = moment(new Date(), "DD/MM/YYYY HH:mm:ss");
var then = moment(new Date(startDate), "DD/MM/YYYY HH:mm:ss");
var diffTime = moment.duration(then.diff(now));   
and it depends  to you how you want to get difference in seconds ,minutes  or hours :
diffTime.asHours();
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