如何使用通用时间约定将日期转换为字符串?

htmljavascriptprogramming scripts

要使用通用时间约定将日期转换为字符串,请使用 toUTCString() 方法。它使用通用时间约定将日期转换为字符串并返回。

示例

您可以尝试运行以下代码来了解如何使用 UTC 将日期转换为字符串 −

<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>

相关文章