Home > Web Front-end > JS Tutorial > body text

Detailed explanation of the use of setFullYear() method in JavaScript_Basic knowledge

WBOY
Release: 2016-05-16 15:55:39
Original
2042 people have browsed it

The javascript Date.setFullYear() method will specify the date of the whole year according to local time.
Grammar

Date.setFullYear(yearValue[, monthValue[, dayValue]])

Copy after login

Note: Parameters in brackets are optional

Here are the details of the parameters:

  • yearValue: an integer specifying the numeric value of the year, for example, 2008
  • monthValue: month January to December represented by an integer from 0 to 11
  • dayValue: an integer between 1 and 31, representing the day of the month. If you specify the dayValue parameter, you must also specify monthValue

If the monthValue and dayValue parameters are not specified, the values ​​returned by the getMonth and getDate methods are used
Return value:

  • NA

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>

Copy after login

This will produce the following results:

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

Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!