Set the year of the UTC date with setUTCFullYear(year) in JavaScript

Description

The following code shows how to set the year of the UTC date with setUTCFullYear(year).

Example


<!--from ww w.ja  v  a  2s  . c o m-->
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var myDate = new Date();
myDate.setUTCFullYear(2012);
document.writeln(myDate);
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Set the year of the UTC date with setUTCFullYear(year) in JavaScript
Home »
  Javascript Tutorial »
    Data Type »
      Date
...
Get the date's seconds as a number between ...
Get the day of the month (1 through 31) for...
Get the day of the month (1 through 31) for...
Get the four-digit year (2007 instead of ju...
Get the four-digit year of the UTC date val...
Get the milliseconds representation of the ...
Get the month name for UTC time in JavaScri...
Get the month of the UTC date, where 0 repr...
Get the month of the date, where 0 represen...
Get the number of minutes that the local ti...
Get year, month and day from date differenc...
Parse an invalid date in JavaScript
Pass a string date value in format of "ISO ...
Parse a string date value in format of "day...
Pass a string date value in format of "mont...
Pass a string date value in format of "mont...
Pass in more value for UTC() function in Ja...
Return Date string in timezone information ...
Set the UTC date's hours with setUTCHours(h...
Set the UTC date's milliseconds with setUTC...
Set the UTC date's minutes with setUTCMinut...
Set the UTC date's seconds with setUTCSecon...
Set the date's hours with with setHours(hou...
Set the date's milliseconds with setMillise...
Set the date's minutes with setMinutes(minu...
Set the date's seconds with setSeconds(seco...
Set the day of the month for the UTC date w...
Set the day of the month for the date with ...
Set the milliseconds representation of the ...
Set the month of the UTC date with setUTCMo...
Set the month of the date with setMonth(mon...
Set the year of the UTC date with setUTCFul...
Set the year of the date with setFullYear(y...
Time statements with Date object in JavaScr...
Translate the Date().getDay() to a string d...
Translate the Date().getMonth() to month na...
Use Date.getDay() with switch statement in ...
Use Date.getMonth() with switch statement i...
...