Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
Date.now() は静的メソッドで、 UTC (協定世界時) で 1970 年 1 月 1 日の夜半と定義されている元期からの経過時間を、ミリ秒単位で返します。
なし。
現在時刻のタイムスタンプをミリ秒単位で表す数値です。
タイミング攻撃やフィンガープリンティングに対する保護機能を提供するために、 someFile.lastModified の精度がブラウザーの設定に応じて丸められることがあります。 Firefox では、privacy.reduceTimerPrecision 設定は既定で有効になっており、既定で 2 ミリ秒になります。この場合、精度は 100ms または privacy.resistFingerprinting.reduceTimerPrecision.microseconds の値のどちらか大きい方になります。
例えば、時刻の精度を下げた場合、 Date.now() の結果は常に 2 の倍数になり、privacy.resistFingerprinting を有効にした場合は 100 の倍数(または privacy.resistFingerprinting.reduceTimerPrecision.microseconds)になります。
Date.now() を使用して現在の時刻をミリ秒単位で取得し、前回の時刻を差し引くと、2 つの呼び出し間の経過時間を求めることができます。
より複雑なシナリオでは、パフォーマンス API を使用することをお勧めします。
| ECMAScript® 2027 Language Specification # sec-date.now |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年6月16日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.