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

Thiết lập mili-giây cho ngày theo giờ UTC

Phương thức setUTCMilliseconds() thiết lập mili-giây (0-999) cho đối tượng Date theo giờ phổ thông (UTC).

Tham số:

  • millisecondsValue – Số nguyên 0 đến 999.

Ví dụ

<html>
  <head>
    <title>JavaScript setUTCMilliseconds Method</title>
  </head>
  <body>
    <script>
      var dt = new Date("Aug 28, 2008 23:30:00");
      dt.setUTCMilliseconds(1200); // 1200 ms = 1.2 giây, sẽ tự động chuyển sang giây
      document.write(dt);
    </script>
  </body>
</html>