The getFullYear method returns the year value of the point in time stored in a Date object. The value returned by this method is an integer number with all the digits of the year in question.
Syntax
myDate.getFullYear()
With myDate being an object based on the Date object.
Instead of being instantiated from a class, in JavaScript objects are created by replicating other objects. This paradigm is called Prototype-based programming.
Example
The following code uses the getFullYear method to return the year of the current date:
<script type="text/javascript">
var myDate = new Date();
var currentYear = myDate.getFullYear();
document.write("The current year is: " + currentYear + ".");
</script>
var myDate = new Date();
var currentYear = myDate.getFullYear();
document.write("The current year is: " + currentYear + ".");
</script>
Technical Details
The getFullYear method belongs to the Date object, it is available since the version 1.3 of JavaScript, and it is supported in all major browsers.
JavaScript Manual >> Date Object >> getFullYear Method