Sets the year of the date

Description

setFullYear(year)
Sets the year of the date. The year must be given with four digits (2007 instead of just 07).

Example


      var myDate = new Date();
      /*  w ww. j  a  v a 2 s .  c o m*/
      myDate.setFullYear(2012);
      console.log(myDate.toString());
      

The code above generates the following result.





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window