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

220
Vistas
How to get the current month and the next months until next year in javascript

so I want to get the current month and the next 12 months in vanilla js. For example, upon writing this question it's April 2022, So I want to have this output:

April 2022 May 2022 June 2022 July 2022 August 2022 September 2022 October 2022 November 2022 December 2022 January 2023 February 2023 March 2023 April 2023

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

0

for (let i = 0; i < 13; i++) {
  let month = new Date().getMonth() + 1 + i;
  let year = new Date().getFullYear();
  if (month > 12) {
    month = month - 12;
    year = year + 1;
  }
  const nameMonth = {
    1: "Jan",
    2: "Feb",
    3: "Mar",
    4: "Apr",
    5: "May",
    6: "Jun",
    7: "Jul",
    8: "Aug",
    9: "Sep",
    10: "Oct",
    11: "Nov",
    12: "Dec",
  };
  console.log(year + " Year " + nameMonth[month] + " Month ");
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

for (let i = 0; i < 13; i++) {
  let month = new Date().getMonth() + 1 + i;
  let year = new Date().getFullYear();
  if (month > 12) {
    month = month - 12;
    year = year + 1;
  }
  const nameMonth = {
    1: "Jan",
    2: "Feb",
    3: "Mar",
    4: "Apr",
    5: "May",
    6: "Jun",
    7: "Jul",
    8: "Aug",
    9: "Sep",
    10: "Oct",
    11: "Nov",
    12: "Dec",
  };
  console.log(
    year + " Year " + nameMonth[month] + " Month "
  );
}
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