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

192
Vistas
JavaScript date bug with the date 1700-01-01 and earlier?

I was working on a JavaScript application where I set the default "starting date" to 1700-01-01 if the user only selects an "ending date" and doesn't select a beginning date. I chose 1700-01-01 because that's the earliest date that can be stored in a Microsoft SQL Server (or at least the default value). I then store this value in local storage and parse it again later. So effectively I execute these three commands at some point:

testDate = new Date(1700, 0, 1, 0, 0, 0, 0)
testDateStr = testDate.toString()
testDateReparsed = new Date(testDateStr)
console.log(testDateReparsed );

However, testDateReparsed ends up being the date: Thu Dec 31 1699 23:59:24!

This same behavior doesn't happen with dates after 1700-01-01, and also happens with dates before 1700-01-01. So if I repeated the same code except the year was 2000 instead of 1700, testDateReparsed would be 2000-01-01 as expected. If the year was 1500 instead of 1700, testDateReparsed would be 1499-12-31 like with the year 1700.

What is the cause of this? Is this a know JavaScript bug or am I missing something?

about 4 years ago · Juan Pablo Isaza
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