The getFullYear() Method

The getFullYear() method returns the year of a date as a four digit number:

HTML file: Displayed by browser:
<body>
<h4>The year today, using the getFullYear method:</h4>
<p id="demo"></p>
<script>
var d = new Date();
document.getElementById("demo").innerHTML = d.getFullYear();
</script>
</body>

The year today, using the getFullYear method:


BackTable of ContentsNext