Copyright © tutorialspoint.com

Javascript Date setYear() Method

previous next

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:

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

Copyright © tutorialspoint.com