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

Thiết lập phút cho Date theo giờ UTC

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

Tham số:

  • minutesValue – 0-59.
  • secondsValue (tùy chọn) – 0-59, bắt buộc có minutesValue.
  • msValue (tùy chọn) – 0-999, bắt buộc có minutesValue và secondsValue.

Ví dụ

<html>
  <head>
    <title>JavaScript setUTCMinutes Method</title>
  </head>
  <body>
    <script>
      var dt = new Date("Aug 28, 2008 13:30:00");
      dt.setUTCMinutes(85); // 85 phút = 1h25p, tự động tràn sang giờ
      document.write(dt);
    </script>
  </body>
</html>