From http://www.w3schools.com (Copyright Refsnes Data)
JavaScript Date Object
The getFullYear() method returns a four-digit number that represents a year.
| dateObject.getFullYear() |
Note: This method is always used in conjunction with a Date object.
Example 1Get the current year and print it:
The output of the code above will be: Try it yourself » |
Example 2Extract the year out of a specific date:
The output of the code above will be:
Try it yourself » |
JavaScript Date Object
From http://www.w3schools.com (Copyright Refsnes Data)