Javascript Date getFullYear()

Introduction

Javascript Date getFullYear() method returns the four-digit year (2019 instead of just 19).

var today = new Date();
var year = today.getFullYear();
console.log(year);/*ww w  .  j  a  v a  2s. co m*/

Get full year for a specific date.

var d = new Date("July 21, 2010 01:15:00"); 
var n = d.getFullYear();
console.log(n);//from w w  w  . j  av a  2 s.co  m



PreviousNext

Related