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

223
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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