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

124
Visualizações
dayjs: date supplied from mongodb is at least 5 minutes old

I'm using dayjs and trying to figure out how to check if a date is at least 5 minutes ago.

Here is an example of a date: 2021-11-04T12:20:46.485Z

Its probably some subtracting and adding 5 somewhere but the MongoDB format and dayjs is somewhat confusing.

Ref ? https://day.js.org/docs/en/query/is-after

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Check this out:

Using vanilla JS date object, you can find the difference in minutes between two dates. Example:

const today = new Date(); // This represents the current date + time

const difference = parseInt(
   (Math.abs(today.getTime() - OTHERDATEOBJECT.getTime()) / (1000 * 60)) % 60);

// Handling the difference
if (difference > 5) {
   // Do something if it was at least 5 minutes ago
} else {
   // If not 5 minutes ago, do something else
}

If you are passing it a date string, you may need to create a new date object with it before you can compare it to your "today" date object

like so:

const difference = parseInt(
   (Math.abs(today.getTime() - (new Date(OTHERDATE)).getTime()) / (1000 * 60)) % 60);
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