Get the Current Year in JavaScript – How to Guide datejavascript How do I get the current year in JavaScript? Best Answer 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. Related Solutions Related Question
Best Answer
Create a
new Date()
object and callgetFullYear()
:Example usage: a page footer that always shows the current year:
See also, the
Date()
constructor's full list of methods.