如何使用世界時將日期轉換為字串?


如要使用世界時將日期轉換為字串,請使用 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>

更新於: 2020 年 6 月 23 日

115 次瀏覽

開啟您的職業

完成課程以獲取認證

開始
廣告
© . All rights reserved.