ホーム > Date > setMilliseconds

setMilliseconds

地方時に基づき,日付の「ミリ秒」を設定します.

シンタックス

dateObject.setMilliseconds(millisec)
  • millisec - ミリ秒 (0から999)

解説

setMillisecondsメソッドは地方時に基づき,ミリ秒を設定します.

サンプルコード

以下にsetMillisecondsメソッドを使用したサンプルコードを示します.

<html>
  <head>
    <title>setMillisecondsメソッドのサンプルコード</title>
  </head>
  <body>
    <script type="text/javascript" language="javascript">
      /* 1950/10/02 23:59:59 */
      var dt = new Date("October 2, 1950 23:59:59");
      document.write("ミリ秒: " + dt.getMilliseconds() + "<br />");

      /* ミリ秒を変更 */
      dt.setMilliseconds(999);
      document.write("変更後: " + dt.getMilliseconds() + "<br />");
    </script>
  </body>
</html>

実行例

サンプルコードの実行結果は以下のようになります.

ミリ秒: 0
変更後: 999

関連項目

スポンサード リンク

inserted by FC2 system