Get the First Day of Next Month in JavaScript


Borislav Hadzhiev

Last updated: Oct 25, 2021


Photo from Unsplash

Get the First Day of Next Month #

To get the first day of the next month, use the Date() constructor to create a date object, passing it the year, the current month + 1, and 1 for the day as parameters. The Date object will contain the first day of the next month.

function getFirstDayOfNextMonth() { const date = new Date(); return new Date(date.getFullYear(), date.getMonth() + 1, 1); } // 👇️ Mon Nov 01 ... console.log(getFirstDayOfNextMonth());

We passed the following 3 parameters to the Date() constructor:

  1. The year
  2. The month - notice that we added 1 to get the next month.
  3. The day

For the year, we used the Date.getFullYear method.

To get the month, we used the Date.getMonth method and added one to the result to get a date object for the next month.

The getMonth method returns a zero-based month index from 0 to 11, meaning January is 0 and December is 11.

The return value from getMonth is not very relevant in this use case, however it's good to be aware of.

For the days slot, we simply hardcoded 1.

Note that, even if the next month is January, the year would get rolled over and we would still get the correct date back.

// 👇️ Thu Jan 01 2026 console.log(new Date(2025, 11 + 1, 1));

In this example, we passed 2025 as the year and 12 as the month, however months are 0 based in JavaScript, meaning they go 0 (January) to 11 (December), so by passing 12 in the months slot, we rolled over the date to next year.

Because of how dates work in JavaScript our solution would get the next month correctly, even if it is January of the next year.

Further Reading #

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.