Home >>JavaScript Date Object Methods >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()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
getFullYear() | Yes | Yes | Yes | Yes | Yes |
<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>
Click the button to see the Output.