.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.

Code
Output
Loading...

All contributors

Looking to contribute?

Learn JavaScript on Codecademy