Date.getFullYear()
JavaScript 1.2+, ECMAScript 1.0+, JScript 3.0+ Nav4+, IE 4+ Syntax
date.getFullYear()
Description
The getFullYear() method returns the year in local time as a full four-digit number.
Example
The code in Listing 6.73 displays the year using the getFullYear() method.
Listing 6.73 Using the getFullYear() Method to Return the Year
<html> <script language="JavaScript"> <!-- Hide //Create a Date object that contains the current date and time. theDate = new Date(); //Display the full year document.write("The year is ",theDate.getFullYear()); //Hide End --> </script> </html> |
Get Pure JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.