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.
W3Schools
w3schools.com › jsref › jsref_getfullyear.asp
JavaScript Date getFullYear() Method
cssText getPropertyPriority() getPropertyValue() item() length parentRule removeProperty() setProperty() JS Conversion ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
Top answer 1 of 13
2732
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.
2 of 13
316
// Return today's date and time
var currentTime = new Date()
// returns the month (from 0 to 11)
var month = currentTime.getMonth() + 1
// returns the day of the month (from 1 to 31)
var day = currentTime.getDate()
// returns the year (four digits)
var year = currentTime.getFullYear()
// write output MM/dd/yyyy
document.write(month + "/" + day + "/" + year)
Videos
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getFullYear
Date.prototype.getFullYear() - JavaScript - MDN Web Docs
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 - W3Schools JavaScript Date Reference - A beginner-friendly reference that includes examples and simple explanations of how to work with dates in JavaScript. Stack Overflow - For real-world problems and solutions, I often browse through questions on Stack Overflow. It’s a valuable community resource when I run into issues or need alternative approaches. Learning to get the current year ...
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 ...
Scaler
scaler.com › home › topics › get current year in javascript
Get the Current Year in JavaScript - Scaler Topics
May 4, 2023 - The returned year is in the format of a four-digit number. In this article, we will discuss all the topics related to this method with examples and explanations where ever necessary. A Date is a built-in object present in JavaScript that is used to handle the operations related to the date and time. We can use make use of the Date object for displaying the date and time that corresponds to the current date and local time of that particular user zone.
W3Schools
w3schools.sinsixx.com › jsref › jsref_getyear.asp.htm
JavaScript getYear() Method - SinSiXX - W3Schools
Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getYear
Date.prototype.getYear() - JavaScript - MDN Web Docs
July 10, 2025 - The getYear() method of Date instances returns the year for this date according to local time. Because getYear() does not return full years ("year 2000 problem"), it is deprecated and has been replaced by the getFullYear() method.
W3Schools
w3schools.com › js › js_dates.asp
JavaScript Dates
February 4, 2026 - Date methods allow you to get and ... covered in the next chapters. JavaScript will (by default) output dates using the toString() method....
Futurestud.io
futurestud.io › tutorials › get-the-current-year-in-javascript-or-node-js
Get the Current Year in JavaScript or Node.js - Future Studio
**Retrieve the year number from a JavaScript date using the getFullYear() method:
TutorialsPoint
tutorialspoint.com › javascript › date_getyear.htm
JavaScript Date getYear() Method
Returns the year in the specified date according to universal time. Try the following example. <html> <head> <title>JavaScript getYear Method</title> </head> <body> <script type = "text/javascript"> var dt = new Date(); document.write("getYear() : " + dt.getYear() ); </script> </body> </html>
Technogeeks CS
technogeekscs.com › home › how to get current year in javascript
How to get Current Year in JavaScript
April 9, 2025 - In the given example, we will be using the current year method in the html page. This html page will help us to get the year by using the getFullYear method. Here we had used H1 and H2 Tags for displaying the title.
Call 8600998107
Address 3rd Floor, Plot No 7, Common Wealth Society , Opposite Aundh Telephone Exchange, Landmark : Gaikward Petrol Pump Aundh,, 411007, Pune
Squash
squash.io › how-to-get-the-current-year-in-javascript
How to Get the Current Year in Javascript - Squash Labs
April 29, 2024 - Below are two possible approaches to retrieve the current year: The Date object in JavaScript has a method called getFullYear that returns the current year as a four-digit number.