Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Thiết lập giây cho Date theo giờ UTC

Phương thức setUTCSeconds() thiết lập giây (và tùy chọn mili-giây) cho Date theo UTC.

Tham số:

  • secondsValue – 0-59.
  • msValue (tùy chọn) – 0-999.

Ví dụ

<html>
  <head>
    <title>JavaScript setUTCSeconds Method</title>
  </head>
  <body>
    <script>
      var dt = new Date("Aug 28, 2008 13:30:00");
      dt.setUTCSeconds(65); // 65s = 1p5s, tràn sang phút
      document.write(dt);
    </script>
  </body>
</html>