Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!