StopWatch (ネクストエクスペリエンス): クライアント

  • リリースバージョン: Zurich
  • 更新日 2025年07月31日
  • 所要時間:2分
  • StopWatch API には、ネクストエクスペリエンス UI フレームワーク内の期間を測定するメソッドが用意されています。

    表 : 1. プロパティ
    名前 タイプ 説明
    started 日付オブジェクト ストップウォッチの開始日時。この値は、コンストラクタ StopWatch(Object started) または restart() メソッドを呼び出すときに設定されます。

    StopWatch (ネクストエクスペリエンス):StopWatch (オブジェクトが開始されました)

    新しい StopWatch を初期化するコンストラクター。

    表 : 2. パラメーター
    名前 タイプ 説明
    started 日付オブジェクト オプション。ストップウォッチの開始時間として使用する日付と時刻。

    デフォルト:現在の日付と時刻。

    この例では、現在の日付と時刻から始まる新しい StopWatch を初期化します。

    var timer = new nowapi.StopWatch();

    ストップウォッチ (ネクストエクスペリエンス):getTime()

    ストップウォッチが開始されてからの経過時間をミリ秒単位で返します。

    表 : 3. パラメーター
    名前 タイプ 説明
    なし
    表 : 4. 返される内容
    タイプ 説明
    番号 ストップウォッチが開始されてからの経過時間。

    単位:ミリ秒

    この例では、経過した StopWatch 時間をミリ秒単位で返します。

    var timer = new nowapi.StopWatch();
    console.log(timer.started);  //logs the StopWatch start date and time to the console
    var millis = timer.getTime();

    ストップウォッチ (ネクストエクスペリエンス) - restart()

    ストップウォッチの開始時刻を現在の日付と時刻にリセットします。

    表 : 5. パラメーター
    名前 タイプ 説明
    なし
    表 : 6. 返される内容
    タイプ 説明
    なし

    この例では、タイマーが開始して再起動してから経過したミリ秒数を返します。

    var timer = new nowapi.StopWatch();
    console.log(timer.started);  //logs the StopWatch start date and time to the console
    timer.getTime();  //milliseconds since the timer started
    timer.restart();
    console.log(timer.started);  //logs the new StopWatch start date and time to the console
    timer.getTime();  //milliseconds since the timer restarted

    StopWatch (ネクストエクスペリエンス):toString()

    ストップウォッチが起動してからの経過時間を ISO 8601 形式 (HH:mm:ss.sss) で返します。

    表 : 7. パラメーター
    名前 タイプ 説明
    なし
    表 : 8. 返される内容
    タイプ 説明
    文字列 時、分、秒、ミリ秒を含む ISO 8601 形式の期間 (HH:mm:ss.sss)。

    この例では、経過した StopWatch 時間を HH:mm:ss.sss の形式で返します。

    var timer = new nowapi.StopWatch();
    var duration = timer.toString();