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

Chuyển đổi Date thành chuỗi theo quy ước UTC

Phương thức toUTCString() chuyển Date thành chuỗi theo giờ phổ thông (UTC/GMT).

Ví dụ

<html>
  <head>
    <title>JavaScript toUTCString Method</title>
  </head>
  <body>
    <script>
      var dateobject = new Date(2018, 0, 15, 14, 39, 7);
      document.write(dateobject.toUTCString());
    </script>
  </body>
</html>