JavaScript getFullYear () method

Source: Internet
Author: User

JavaScript Date Object

Definition and usage

The getFullYear () method returns a 4-digit number that represents the year.

Grammar
Dateobject.getfullyear ()
return value

The year that is returned when Dateobject is represented in local time. The return value is a four-digit number that represents the full year, including the century value, rather than the abbreviated form of a two-digit number.

Tips and Comments:

Note: This method is always used in conjunction with a Date object.

Example 1

In this example, we will get the current year and output it:

<script type= "Text/javascript" >var d = new Date () document.write (D.getfullyear ()) </script>

Output:

2017
Example 2

In this example, we will extract the year from the specific date:

<script type= "Text/javascript" >var born = new Date ("July, 1983 01:15:00") document.write ("I was born in" + BORN.G Etfullyear ()) </script>

Output:

I was born in 1983
Tiy
Display the current date in a different format
How to use GetDate (), GetMonth (), and getFullYear () to display the current date in a different format.

JavaScript Date Object

JavaScript getFullYear () method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.