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

86
Visualizações
Strange date behavior with mongoose

I have a document in my database that gets displayed like this when inspected with MongoDB Compass:

mongodb object

Now I have experimented a bit with it on the command line:

command line experiments

I understand that getMonth returns one because they range from 0 to 11, but why does getDay return numbers that to me appear have no relation whatsoever with the saved date?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

getDay() returns the day of the week (from 0-6).

So wednesday will be 2.

Try getDate() to return the day of the month.

over 4 years ago · Santiago Trujillo Relatório

0

if you look documentation for getDay() you will find out that:

The getDay() method returns the day of the week (from 0 to 6) for the specified date.

I think that on your computer culture week starts on Sunday. So you are getting numbers that you are gettings.

Also I bolive that you wanted to use getDate() method:

The getDate() method returns the day of the month (from 1 to 31) for the specified date.

over 4 years ago · Santiago Trujillo 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