Home > Web Front-end > HTML Tutorial > Set the hour of a specified date based on UTC?

Set the hour of a specified date based on UTC?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-09-02 19:49:16
forward
736 people have browsed it

Set the hour of a specified date based on UTC?

JavaScript date setUTCHours() method sets the hour of the specified date based on local time. The following is the parameter list of setUTCHours(hoursValue[, minutesValue[, secondsValue[, msValue]]]):

  • hoursValue − an integer between 0 and 23, Indicates the hour.
  • minutesValue − An integer between 0 and 59 representing minutes.
  • secondsValue − An integer between 0 and 59 representing seconds. If the secondsValue parameter is specified, minutesValue must also be specified.
  • msValue − A number between 0 and 999 representing milliseconds. If the msValue parameter is specified, both minutesValue and secondsValue must be specified.

Example

You can try running the following code to set the hour of a specified date based on UTC:

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

The above is the detailed content of Set the hour of a specified date based on UTC?. For more information, please follow other related articles on the PHP Chinese website!

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