Home >Web Front-end >JS Tutorial >How to use the setYear() method to manipulate time in JavaScript_Basic knowledge
The javascript Date.setYear() method sets the specified year according to the universal time.
Grammar
Date.setYear(yearValue)
Note: Data in brackets are optional
Here are the details of the parameters:
Return value:
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 the following results:
Mon Aug 28 13:30:00 UTC+0530 2000