Home >>JavaScript Date Object Methods >JavaScript getFullYear() Method

JavaScript getFullYear() Method

JavaScript getFullYear() Method

JavaScript getFullYear() method is used to return the year of the given input date. It returns a four digit integer value between year 1000 and 9999.

Syntax:
Date.getFullYear()

Browser Support

Method Chrome Edge Firefox Safari Opera
getFullYear() Yes Yes Yes Yes Yes
Here is an example of JavaScript getFullYear() method:
<html>
<body>
<p>Click the button to see the Output.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() 
{
  var d = new Date();
  var n = d.getFullYear();
  document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
Output:

Click the button to see the Output.


No Sidebar ads