JavaScript .getFullYear()

StevenSwiniarski's avatar
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.

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours

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.

Code
Output

All contributors

Contribute to Docs

Learn JavaScript on Codecademy

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours