Tutorials Point


  JavaScript Basics
  JavaScript Objects
  JavaScript Advanced
  JS Useful References
  JS Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Javascript Date setYear() Method


previous next AddThis Social Bookmark Button


Advertisements

Description:

Javascript date setYear() method sets the year for a specified date according to universal time.

Syntax:

Date.setYear(yearValue)

Note: Paramters in the bracket are always optional

Here is the detail of parameters:

  • yearValue : An integer value.

Return Value:

NA

Example:

<html>
<head>
<title>JavaScript setYear Method</title>
</head>
<body>
<script type="text/javascript">
   var dt = new Date( "Aug 28, 2008 13:30:00" );
   dt.setYear( 2000 );
   document.write( dt ); 
</script>
</body>
</html>

This will produce following result :

Mon Aug 28 13:30:00 UTC+0530 2000 

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements