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

145
Vistas
JS new Date() jump to next year

For a few days, I have had a problem with the date processed by JS, which would try to make the year jumps forward. A bit of sample code below.

Inicjal date in HTML 'Jan 19 2022'

  var dateYear = $(this).attr("dateYear");
  console.log('dateYear ' + dateYear); // dateYear 2022

  var dateMonth = $(this).attr("dateMonth");
  console.log('dateMonth ' + dateMonth); // dateMonth 12
  var dateDay = $(this).attr("dateDay");
  console.log('dateDay ' + dateDay); // dateDay 19
    
  var myDate = new Date(dateYear, dateMonth, dateDay);
  console.log('myDate ' + myDate); // myDate Thu Jan 19 2023 00:00:00 GMT+0000 (Greenwich Mean Time)

Even if it subtracts one index from a month, but the year jump to 2023, if the index of the month remains unchanged teddy data will be 'Feb 19 2022';

What could it be for two years there was no problem with the date.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is JavaScript.

January is 0.

December is 11.

See Date.prototype.getMonth().

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