StopWatch (Next Experience) - Client

  • Release version: Australia
  • Updated March 12, 2026
  • 1 minute to read
  • The StopWatch API provides methods to measure durations in the Next Experience UI Framework.

    Table 1. Properties
    Name Type Description
    started Date object Start date and time for the StopWatch. This value is set when calling the constructor StopWatch(Object started) or the restart() method.

    StopWatch (Next Experience) - StopWatch(Object started)

    Constructor to initialize a new StopWatch.

    Table 2. Parameters
    Name Type Description
    started Date object Optional. Date and time to use as the start time for the StopWatch.

    Default: The current date and time.

    This example initializes a new StopWatch starting at the current date and time.

    var timer = new nowapi.StopWatch();

    StopWatch (Next Experience) - getTime()

    Returns the elapsed time in milliseconds since the StopWatch started.

    Table 3. Parameters
    Name Type Description
    None
    Table 4. Returns
    Type Description
    Number Elapsed time since the StopWatch started.

    Unit: Milliseconds

    This example returns the elapsed StopWatch time in milliseconds.

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

    StopWatch (Next Experience) - restart()

    Resets the StopWatch start time as the current date and time.

    Table 5. Parameters
    Name Type Description
    None
    Table 6. Returns
    Type Description
    None

    This example returns the elapsed milliseconds since the timer started and restarted.

    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 (Next Experience) - toString()

    Returns the elapsed time in ISO 8601 format (HH:mm:ss.sss) since the StopWatch started.

    Table 7. Parameters
    Name Type Description
    None
    Table 8. Returns
    Type Description
    String Duration in ISO 8601 format containing hours, minutes, seconds, and milliseconds (HH:mm:ss.sss).

    This example returns the elapsed StopWatch time in the format HH:mm:ss.sss.

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