The getFullYear() method returns the year as four digits for dates between year 1000 and 9999 from the date object.
The getFullYear() method returns the year as four digits for dates between year 1000 and 9999 from the date object.
Date.getFullYear()
None
A Number, representing the year of the specified date
Return the year:
//display the full year of todays date. var d = new Date(); var n = d.getFullYear(); console.log(n);/*from w w w . ja v a 2 s.co m*/ //Return the year of a specific date: //display the full year of a given date. var d = new Date("July 21, 2010 01:15:00"); var n = d.getFullYear(); console.log(n);