Get Current Year, Month and Day using JavaScript


Borislav Hadzhiev

Sun Oct 24 20212 min read


Photo by Erwan Hesry

Get the Current Year in JavaScript #

To get the current year, month and day, create a Date object using the new Date() constructor and call the getFullYear(), getMonth() and getDate() methods on the object.

const currentYear = new Date().getFullYear(); const currentMonth = new Date().getMonth() + 1; const currentDay = new Date().getDate(); const together = [currentYear, currentMonth, currentDay].join('/'); console.log(together); // 👉️ 2025/10/24 // 👇️ Get Names of Month instead of Digits const nameOfMonthUS = new Intl.DateTimeFormat('en-US', {month: 'long'}).format( new Date(), ); console.log(nameOfMonthUS); // 👉️ October const nameOfMonthDE = new Intl.DateTimeFormat('de-DE', {month: 'long'}).format( new Date(), ); console.log(nameOfMonthDE); // 👉️ Oktober

We used the Date() constructor to get a Date object, on which we can call various methods.

We called the following methods on the Date object:

  • Date.getFullYear method - returns a four-digit number representing the year that corresponds to a date.

  • Date.getMonth - returns an integer between 0 (January) and 11 (December) and represents the month for a given date. Yes, unfortunately the getMonth method is off by 1.

  • Date.getDate - returns an integer between 1 and 31 representing the day of the month for a specific date.

Both getFullYear and getDate are intuitive, however the getMonth method is zero-based, this is why we added 1 to the result of calling the method in the example.

In our last 2 examples, we used the Intl.DateTimeFormat object to get the names of the current month, in english and german.

The getFullYear, getMonth and getDate methods allow you get the year / month / day for any date object, it doesn't have to be the current year.

All you have to do is pass the specific date into the Date constructor on which you call the methods.

const date = new Date('September 24, 2025 15:24:23'); const yearOfDate = date.getFullYear(); // 👉️ 2025 const monthOfDate = date.getMonth() + 1; // 9 const dayOfMonth = date.getDate(); // 24 const together = [yearOfDate, monthOfDate, dayOfMonth].join('/'); console.log(together); // 👉️ 2025/9/24
Always keep in mind that the getMonth method is zero-based, like the index of an array or string. To get an intuitive result add 1 to the return value of the method.

Further Reading #

Use the search field on my Home Page to filter through my more than 1,000 articles.