Skip to content
Advertisements

JavaScript Date.getFullYear()

Why getFullYear ?

The JavaScript Date.getFullYear () method returns the year of the specified date by local time. The value returned by GetFullYear () is an absolute number. Used for dates between 1000 and 9999. For example; 1998 is a four-digit date.

Syntax:

Date.getFullYear()

return: A Number that represents the year of the specified date.


JavaScript getFullYear Examples

Example 1

JavaScript Date The getFullYear () method will return the date to you.

        var date = new Date("December 25, 1998 23:15:00");
        console.log("Date.getFullYear() : " + date.getFullYear());

output:

Date.getFullYear() : 1998


Example 2

It doesn’t have to be written in 4 digits.

        var date = new Date("December 25, 78 23:15:00");
        console.log("Date.getFullYear() : " + date.getFullYear());

output:

Date.getFullYear() : 1978


Example 3

        var now = new Date();
        console.log(now.getFullYear());

output:

2019


Browser Support

Chromeyes
Edgeyes
Firefox1
Internet Exploreryes
Operayes
Safariyes
Android webviewyes
Chrome for Androidyes
Edge mobileyes
Firefox for Android4
Opera Androidyes
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: