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

167
Vistas
The method isBefore from momentjs does not work

I want to check if one of the date is before taking into account the minute;

// 1610459035000 Tuesday, 12 January 2021 13:43:55
// 1642081435000 Thursday, 13 January 2022 13:43:55
const a = moment(1610459035000).isBefore(1642081435000, 'minute');
console.log(a) //get true but expect false
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>

Making console.log(a) i expect to get false because the minutes are the same in both cases even if the years are difefrent.
Why i get true if minutes are the same?

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

0

See the docs.

The second argument limits precision.

This means that if your dates were 2001-01-01T00:00:10 and 2001-01-01T00:00:05 then normally the one that is five seconds after midnight would be before the one that is 10 seconds after midnight. If you specify 'minute' precision then it would ignore the difference in seconds and treat them as the same time.

On the other hand, 2001-01-01T00:00:00 and 2002-01-01T00:00:00 are different years. If you have minute precision then the seconds are ignored but one is still clearly before the other.

Only the parts of the values that are smaller then the specified level are ignored, not the parts that are larger.

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