Get the First Day of Next Month in JavaScript

avatar

Borislav Hadzhiev

Mon Oct 25 20212 min read

banner

Photo by Jeremy Bishop

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.

index.js
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.

index.js
// ๐Ÿ‘‡๏ธ 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 #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee