如何使用 JavaScript 獲取毫秒時間戳?


要獲取毫秒時間戳,請使用 Date getMilliseconds() 方法。JavaScript date getMilliseconds() 方法會根據本地時間返回指定日期中的毫秒數。getMilliseconds() 返回的值介於 0 和 999 之間。

示例

你可以嘗試執行以下程式碼來獲取毫秒時間戳:

<html>
   <head>
      <title>JavaScript getMilliseconds() Method</title>
   </head>
   <body>
      <script>
         var dt = new Date( );
         document.write("getMilliseconds() : " + dt.getMilliseconds() );
      </script>
   </body>
</html>

更新日期:2020 年 6 月 19 日

2000+ 次瀏覽

開啟您的職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.