地方時に基づき,日付の「ミリ秒」を設定します.
dateObject.setMilliseconds(millisec)
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
スポンサード リンク