Home > Web Front-end > HTML Tutorial > Sets the complete year for the specified date, according to UTC

Sets the complete year for the specified date, according to UTC

王林
Release: 2023-08-29 21:33:02
forward
655 people have browsed it

Sets the complete year for the specified date, according to UTC

JavaScript date setUTCFullYear() method sets the full year of the specified date according to Coordinated Universal Time. The parameters of the

setUTCFullYear(yearValue[, monthValue[, dayValue]]) method are as follows:

  • ##yearValue - an integer representing the value of the year, such as 2008 Year.
  • monthValue - An integer between 0 and 11 representing the month from January to December.
  • dayValue - An integer between 1 and 31 representing the number of days in the month. If the dayValue parameter is specified, monthValue must also be specified.
Example

You can try running the following code to set the full year for a specified date based on UTC:

<html>
   <head>
      <title>JavaScript setUTCFullYear Method</title>
   </head>
   <body>
      <script>
         var dt = new Date( "Aug 28, 2012 23:30:00" );
         dt.setUTCFullYear( 2018 );
         document.write( dt );
      </script>
   </body>
</html>
Copy after login

The above is the detailed content of Sets the complete year for the specified date, according to UTC. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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