Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda