.getFullYear()
Published May 31, 2023Updated Jun 1, 2023
Contribute to Docs
The .getFullYear()
method returns a four digit year for the date according to local time.
Syntax
myDate.getFullYear();
The returned value of the .getFullYear()
method is an integer representing the year for the provided date myDate
.
Codebyte Example
In the example below, the year
variable stores the year returned from a new Date object and then logs it to the console.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner Friendly15 hours