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

87
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 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