Home > Article > Web Front-end > Detailed explanation of the use of setFullYear() method in JavaScript_Basic knowledge
The javascript Date.setFullYear() method will specify the date of the whole year according to local time.
Grammar
Date.setFullYear(yearValue[, monthValue[, dayValue]])
Note: Parameters in brackets are optional
Here are the details of the parameters:
If the monthValue and dayValue parameters are not specified, the values returned by the getMonth and getDate methods are used
Return value:
Example:
<html> <head> <title>JavaScript setFullYear Method</title> </head> <body> <script type="text/javascript"> var dt = new Date( "Aug 28, 2008 23:30:00" ); dt.setFullYear( 2000 ); document.write( dt ); </script> </body> </html>
This will produce the following results:
Mon Aug 28 23:30:00 UTC+0530 2000