# JSDoc: Class: MonotonicClock

# Class: MonotonicClock

## util.MonotonicClock(startTimeopt)

#### new MonotonicClock(startTimeopt)

MonotonicClock offers a convenient way to keep track of time during experiments. An experiment can have as many independent clocks as needed, e.g. one to time responses, another one to keep track of stimuli, etc.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`startTime` | number | <optional> | <time elapsed since the reference point, i.e. the time when the module was loaded> | the clock's start time (in ms)

Source:
  - util/Clock.js, line 10

### Methods

#### (static) getDate(locales, options) → {string}

Get the current timestamp with language-sensitive formatting rules applied.

Note: This is just a convenience wrapper around `Intl.DateTimeFormat()`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`locales` | string | array.string | A string with a BCP 47 language tag, or an array of such strings.
`options` | object | An object with detailed date and time styling information.

Source:
  - util/Clock.js, line 64

##### Returns:

The current timestamp in the chosen format.

Type
  string

#### (static) getDateStr() → {string}

Get the clock's current time in the default format filtering out file name unsafe characters.

Note: This is mostly used as an appendix to the name of the keys save to the server.

Source:
  - util/Clock.js, line 96

##### Returns:

A string representing the current time formatted as YYYY-MM-DD_HH[h]mm.ss.sss

Type
  string

#### getLastResetTime() → {number}

Get the current offset being applied to the high resolution timebase used by this Clock.

Source:
  - util/Clock.js, line 37

##### Returns:

the offset (in seconds)

Type
  number

#### getReferenceTime() → {number}

Get the time elapsed since the reference point.

Source:
  - util/Clock.js, line 50

##### Returns:

the time elapsed since the reference point (in seconds)

Type
  number

#### getTime() → {number}

Get the current time on this clock.

Source:
  - util/Clock.js, line 24

##### Returns:

the current time (in seconds)

Type
  number