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
Bitwise AND Bitwise OR Bitwise NOT Bitwise XOR Bitwise Left Bitwise Right Bitwise Signed JS Misc Operators · : ?. ... () ? x : y => delete in instanceof typeof void JS Precedence JS Promises · all() allSettled() any() catch() finally() race() reject() resolve() then() try() withResolvers() JS Proxy · apply() construct() defineProperty() deleteProperty() get() getOwnPropertyDescriptor() getPrototypeOf() has() isExtensible() ownKeys() preventExtentions() set() setPrototypeOf() JS Reflect
Discussions

jquery - how to display current month, year in javascript using div - Stack Overflow
I'm trying to get a jquery or java-script code for displaying the current month and year in a div, but unable so far. I mean I want to display the current month and year in this format:October 2012... More on stackoverflow.com
🌐 stackoverflow.com
How to get year/month/day from a date object?
alert(dateObj) gives Wed Dec 30 2009 00:00:00 GMT+0800 How to get date in format 2009/12/30? More on stackoverflow.com
🌐 stackoverflow.com
Check if it is the first day of the month or first day of the year
from datetime import datetime today = datetime.now() if today.day == 1: print("It's the first of the month!") if today.month == 1: print("It's the first of the year!") More on reddit.com
🌐 r/learnpython
8
2
February 19, 2020
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
🌐
W3Schools
w3schools.com › js › js_date_methods.asp
JavaScript Get Date Methods
JS Examples JS HTML DOM JS HTML ... ... In JavaScript, date objects are created with new Date(). new Date() returns a date object with the current date and time. ... The get methods above return Local time....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getFullYear
Date.prototype.getFullYear() - JavaScript - MDN - Mozilla
July 10, 2025 - This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015. ... The getFullYear() method of Date instances returns the year for this date according to local time.
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-get-year-month-day-from-date
Get Year, Month and Day from a Date Object in JavaScript | bobbyhadz
May 14, 2018 - The getYearMonthDay function takes a Date object as a parameter and returns the year, month and day of the given date. If the function is called without a Date object, it returns the current year, month and day.
🌐
Envato Tuts+
code.tutsplus.com › home › javascript
How to Get and Set the Day, Month, Year, or Time in JavaScript | Envato Tuts+
June 9, 2023 - You can use the setFullYear() method and pass it the year that you want to set as its first parameter. This method also accepts two more optional parameters, which will represent the month and date value that you want to set respectively.
Find elsewhere
🌐
IncludeHelp
includehelp.com › code-snippets › get-current-date-month-and-year-in-javascript.aspx
Get current date, month and year in JavaScript - IncludeHelp
October 28, 2017 - Note that, it returns value ranging from 0 to 11 for 12 months. This means January is 0 and December is 11. Here is an example, var today = new Date(); var month = today.getMonth(); // Returns 9 console.log(month); // Output: 9 · To get the current year, use the getFullYear() method.
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-get-current-year
How to get the Current Year in JavaScript [for copyright] | bobbyhadz
The Date.getFullYear method returns a number that represents the year of the given date. If you add the code snippet that uses HTML, make sure to place the script tag at the bottom of the body tag, after all of the DOM elements have been declared.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-day-month-and-year-from-date-object-in-javascript
How to get Day Month and Year from Date Object in JavaScript ? - GeeksforGeeks
November 28, 2023 - The getFullYear() to get the full year from the Date object. This method provides the local time zone for the user to extract the day, month, and year from the Date object.
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-get-day-month-and-year-from-a-date-object-in-javascript.php
How to Get Day, Month and Year from a Date Object in JavaScript
Topic: JavaScript / jQueryPrev|Next · You can use the Date object methods getDate(), getMonth(), and getFullYear() to get the date, month and full-year from a Date object. Let's check out an example:
🌐
Attacomsian
attacomsian.com › blog › nodejs-get-current-date-month-year
How to get the current day, month, and year in Node.js
June 15, 2020 - Since Node.js is a cross-platform, open-source JavaScript runtime environment, you can use the Date object methods getDate(), getMonth(), and getFullYear() to get the current day, month, and year in a Node.js application.
🌐
Scaler
scaler.com › home › topics › get current year in javascript
Get the Current Year in JavaScript - Scaler Topics
May 4, 2023 - The example is described below with output and explanation. In this example, we have used the get the getFullYear() method to get the current year that corresponds to the current local time.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getYear
Date.prototype.getYear() - JavaScript - MDN - Mozilla
July 10, 2025 - This method essentially returns the value of getFullYear() minus 1900. You should use getFullYear() instead, so that the year is specified in full. The second statement assigns the value 95 to the variable year. ... The second statement assigns the value 100 to the variable year.
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › date › day, week, month, or quarter of year
Find the day, week, month, or quarter of the year using JavaScript - 30 seconds of code
January 5, 2024 - Finding the month of the year (in the range 1-12) from a Date object is the most straightforward of the bunch. Simply use Date.prototype.getMonth() to get the current month in the range 0-11 and add 1 to map it to the range 1-12.
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › date › first or last date of a month
Get the first or last date of a month using JavaScript - 30 seconds of code
February 17, 2024 - Here's how you can do both using JavaScript. Given any Date object, you can use Date.prototype.getFullYear() and Date.prototype.getMonth() to get the current year and month from the given 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 - const date = new Date(); let day = date.getDate(); let month = date.getMonth() + 1; let year = date.getFullYear(); // This arrangement can be altered based on how we want the date's format to appear. let currentDate = `${day}-${month}-${year}`; ...
🌐
W3Schools
w3schools.com › jsref › jsref_getmonth.asp
JavaScript Date getMonth() Method
cssText getPropertyPriority() ... ... const month = ["January","February","March","April","May","June","July","August","September","October","November","December"]; const d = new Date(); let name = month[d.getMonth()]; Try it Yourself ...