Create a new Date() object and call getFullYear():

new Date().getFullYear()  // returns the current year

Example usage: a page footer that always shows the current year:

document.getElementById("year").innerHTML = new Date().getFullYear();
footer {
  text-align: center;
  font-family: sans-serif;
}
<footer>
     <span id="year"></span> by Stack Overflow
</footer>

See also, the Date() constructor's full list of methods.

Answer from Jason Harwig on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › jsref_getfullyear.asp
JavaScript Date getFullYear() Method
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
Discussions

How to get the current year in JavaScript? - TestMu AI Community
How to get the current year in JavaScript More on community.testmuai.com
🌐 community.testmuai.com
0
May 19, 2024
JavaScript Date(Date)
Your code breaks if it's the first day of the month. And yeah, the built-in JavaScript date type is pretty garbage. I recommend using moment.js instead. More on reddit.com
🌐 r/programminghorror
25
48
July 21, 2017
Is there a way to insert the current year with HTML only?
no. html has no logic. if you are using a templated system in your email send, there should be some function or template tag that can insert it - you (probably) dynamically insert names and other personalization... More on reddit.com
🌐 r/HTML
4
2
May 22, 2024
Get url of current tab from firefox webextension!
You can also write it like this: function buttonClicked() { // query tabs to get current tab browser.tabs.query({currentWindow: true, active:true}).then(queryInfo => { browser.tabs.get(queryInfo[0].id).then(tab => { var tabUrl = tab.url; doSomething(taburl); browser.tabs.update(tab.id, {url: updUrl}); }); }); } More on reddit.com
🌐 r/firefox
4
1
September 2, 2017
🌐
CoreUI
coreui.io › answers › how-to-get-the-current-year-in-javascript
How to get the current year in JavaScript · CoreUI
October 2, 2025 - From my expertise, the most reliable and precise solution is to use the getFullYear() method on a Date object. This approach returns the complete 4-digit year and automatically updates as time progresses, making it perfect for dynamic content.
🌐
Medium
frontendinterviewquestions.medium.com › how-to-get-current-year-in-javascript-4400b75a827e
How to get current year in JavaScript ? | by Pravin M | Medium
September 7, 2024 - JavaScript’s built-in Date object allows you to work with dates and times. To get the current year, you use the Date constructor and call its method getFullYear(), which retrieves the year as a four-digit number (e.g., 2024).
🌐
Altcademy
altcademy.com › blog › how-to-get-current-year-in-javascript
How to get current year in JavaScript
June 9, 2023 - In this tutorial, we've learned how to get the current year in JavaScript using the Date object and the getFullYear() method.
Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getFullYear
Date.prototype.getFullYear() - JavaScript | MDN
July 10, 2025 - const moonLanding = new Date("July 20, 69 00:20:18"); console.log(moonLanding.getFullYear()); // Expected output: 1969 ... An integer representing the year for the given date according to local time.
🌐
DEV Community
dev.to › theudemezue › how-to-get-current-year-in-javascript-49f2
How To Get Current Year In JavaScript - DEV Community
March 8, 2025 - According to MDN Web Docs, the Date object in JavaScript is built specifically to handle dates and times. This makes it a natural choice for extracting information like the current year. By taking advantage of this built-in feature, I ensure that my code stays clean and efficient. At the core of getting the current year in JavaScript is the Date object.
🌐
Codemia
codemia.io › knowledge-hub › path › get_the_current_year_in_javascript
Get the current year in JavaScript
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-the-current-year-using-javascript
How to get the current year using JavaScript ? - GeeksforGeeks
July 15, 2025 - In this article, we will know how to get the current year using the build-in method in Javascript. The purpose is to get the current year by using JavaScript getFullYear() method that will return the full year in 4-digit format for some specified ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-the-first-day-of-the-year-in-javascript
How to get the first day of the year in JavaScript ? - GeeksforGeeks
July 12, 2025 - Given a date/year and the task is to get the first day of the year using JavaScript. Approach 1: Use getFullYear() Method to get the year from the given date. Use the new Date() function to create the new date object using year, month, and day.
🌐
W3docs
w3docs.com › javascript
How Get the Current Year in JavaScript
For the dates between 1000 and 9999 years, the getFullYear() method returns a four-digit number. Create a new Date() object and invoke getFullYear() method to return the current date: Javascript create new date and invoke getFullYear() method
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript | MDN
When called as a function, it returns a string representing the current time. const date1 = new Date("December 17, 1995 03:24:00"); // Sun Dec 17 1995 03:24:00 GMT... const date2 = new Date("1995-12-17T03:24:00"); // Sun Dec 17 1995 03:24:00 GMT... console.log(date1.getTime() === date2.getTime()); // Expected output: true ... new Date() new Date(value) new Date(dateString) new Date(dateObject) new Date(year, monthIndex) new Date(year, monthIndex, day) new Date(year, monthIndex, day, hours) new Date(year, monthIndex, day, hours, minutes) new Date(year, monthIndex, day, hours, minutes, seconds) new Date(year, monthIndex, day, hours, minutes, seconds, milliseconds) Date()
🌐
W3Schools
w3schools.com › js › js_date_methods.asp
JavaScript Get Date Methods
The getFullYear() method returns the year of a date as a four digit number: const d = new Date("2021-03-25"); d.getFullYear(); Try it Yourself » · const d = new Date(); d.getFullYear(); Try it Yourself » · Old JavaScript code might use the ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
Returns the year (usually 2–3 digits) in the specified date according to local time. Use getFullYear() instead.
🌐
Futurestud.io
futurestud.io › tutorials › get-the-current-year-in-javascript-or-node-js
Get the Current Year in JavaScript or Node.js
June 16, 2022 - The JavaScript engine comes with a global Date class. Interacting with dates is an essential part of programming. JavaScript’s Date comes with two methods to retrieve the current year: Date#getYear and Date#getFullYear.
🌐
Scaler
scaler.com › home › topics › get current year in javascript
Get the Current Year in JavaScript - Scaler Topics
May 4, 2023 - Then in the script tag, we have created the function example(). Under this function, we have created the object Date. We used the get current year in the javascript method to get the current year of the date.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-get-current-date-todays-date-in-js
JavaScript Get Current Date – Today's Date in JS
November 7, 2024 - We'll make it more readable and understandable to users by using some JavaScript methods that operate on a date object. The date object supports numerous date methods, but for this article, we only need the current date and will only use three methods: getFullYear() – we will use this method to get the year as a four digit number (yyyy), for example 2022.
🌐
SheCodes
shecodes.io › athena › 56873-how-to-log-the-current-year-in-javascript
[JavaScript] - How to log the current year in JavaScript - | SheCodes
Learn how to use the Date() object and getFullYear() method in JavaScript to log the current year to the console.