Date getFullYear() method with example in JavaScript

JavaScript Date getFullYear() method: Here, we are going to learn about the getFullYear() method of Date class with Example in JavaScript.
Submitted by IncludeHelp, on March 04, 2019

JavaScript Date getFullYear() method

getFullYear() method is a Date's class method and it is used to get the current full year in 4 digits format.

It accepts nothing as the parameter and returns a value between 1000 to 9999.

Syntax:

    var dt = new Date();
    dt.getFullYear();

Examples:

    Input:
    var dt = new Date();
    dt.getFullYear();
    
    Output:
    2019

JavaScript code to get the current full year using getFullYear() method

<html>
<head><title>JavaScipt Example</title></head>

<body>
<script>
	var dt = new Date(); //Date constructor 
	var fullyear = dt.getFullYear(); //getting year in 4 digits format
	//printing full year
	document.write("Year is : " + fullyear);
</script>
</body>
</html>

Output

Year is : 2019

JavaScript Date Object Methods »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.