# Class: Time

## Phaser. Time

This is the core internal game clock. It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens.

#### new Time(game)

  Time constructor.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | A reference to the currently running game.

  Source:
    - time/Time.js, line 15

### Members

#### advancedTiming

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `advancedTiming` | boolean | If true Phaser.Time will perform advanced profiling including the fps rate, fps min/max and msMin and msMax.

  Default Value:
    - false
  Source:
    - time/Time.js, line 50

#### deltaCap

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `deltaCap` | number | If you need to cap the delta timer, set the value here. For 60fps the delta should be 0.016, so try variances just above this.

  Source:
    - time/Time.js, line 87

#### <protected> elapsed

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `elapsed` | number | Elapsed time since the last frame (in ms).

  Source:
    - time/Time.js, line 38

#### events

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `events` | Phaser.Timer | This is a Phaser.Timer object bound to the master clock to which you can add timed events.

  Source:
    - time/Time.js, line 117

#### <protected> fps

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `fps` | number | Frames per second. Only calculated if Time.advancedTiming is true.

  Source:
    - time/Time.js, line 56

#### fpsMax

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `fpsMax` | number | The highest rate the fps has reached (usually no higher than 60fps). Only calculated if Time.advancedTiming is true.

  Source:
    - time/Time.js, line 66

#### fpsMin

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `fpsMin` | number | The lowest rate the fps has dropped to. Only calculated if Time.advancedTiming is true.

  Source:
    - time/Time.js, line 61

#### frames

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `frames` | number | The number of frames record in the last second. Only calculated if Time.advancedTiming is true.

  Source:
    - time/Time.js, line 97

#### game

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | Local reference to game.

  Source:
    - time/Time.js, line 20

#### lastTime

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `lastTime` | number | Internal value used by timeToCall as part of the setTimeout loop

  Source:
    - time/Time.js, line 112

#### msMax

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `msMax` | number | The maximum amount of time the game has taken between two frames. Only calculated if Time.advancedTiming is true.

  Source:
    - time/Time.js, line 77

#### msMin

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `msMin` | number | The minimum amount of time the game has taken between two frames. Only calculated if Time.advancedTiming is true.

  Default Value:
    - 1000
  Source:
    - time/Time.js, line 72

#### <protected> now

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `now` | number | The time right now.

  Source:
    - time/Time.js, line 32

#### <protected> pausedTime

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pausedTime` | number | Records how long the game has been paused for. Is reset each time the game pauses.

  Source:
    - time/Time.js, line 44

#### pauseDuration

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pauseDuration` | number | Records how long the game was paused for in miliseconds.

  Source:
    - time/Time.js, line 102

#### physicsElapsed

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `physicsElapsed` | number | The elapsed time calculated for the physics motion updates. In a stable 60fps system this will be 0.016 every frame.

  Source:
    - time/Time.js, line 82

#### <protected> time

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `time` | number | Game time counter. If you need a value for in-game calculation please use Phaser.Time.now instead.

  Source:
    - time/Time.js, line 26

#### timeCap

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `timeCap` | number | If the difference in time between two frame updates exceeds this value, the frame time is reset to avoid huge elapsed counts.

  Source:
    - time/Time.js, line 92

#### timeToCall

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `timeToCall` | number | The value that setTimeout needs to work out when to next update

  Source:
    - time/Time.js, line 107

### Methods

#### <protected> boot()

  Called automatically by Phaser.Game after boot. Should not be called directly.

  Source:
    - time/Time.js, line 165

#### create(autoDestroy) → {Phaser.Timer}

  Creates a new stand-alone Phaser.Timer object.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `autoDestroy` | boolean | <optional> | true | A Timer that is set to automatically destroy itself will do so after all of its events have been dispatched (assuming no looping events).

  Source:
    - time/Time.js, line 178

  ##### Returns:

  The Timer object that was created.

  Type
    Phaser.Timer

#### elapsedSecondsSince(since) → {number}

  How long has passed since the given time (in seconds).

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `since` | number | The time you want to measure (in seconds).

  Source:
    - time/Time.js, line 360

  ##### Returns:

  Duration between given time and now (in seconds).

  Type
    number

#### elapsedSince(since) → {number}

  How long has passed since the given time.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `since` | number | The time you want to measure against.

  Source:
    - time/Time.js, line 349

  ##### Returns:

  The difference between the given time and now.

  Type
    number

#### removeAll()

  Remove all Timer objects, regardless of their state. Also clears all Timers from the Time.events timer.

  Source:
    - time/Time.js, line 197

#### reset()

  Resets the private _started value to now and removes all currently running Timers.

  Source:
    - time/Time.js, line 371

#### totalElapsedSeconds() → {number}

  The number of seconds that have elapsed since the game was started.

  Source:
    - time/Time.js, line 339

  ##### Returns:

  The number of seconds that have elapsed since the game was started.

  Type
    number

#### <protected> update(time)

  Updates the game clock and if enabled the advanced timing data. This is called automatically by Phaser.Game.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `time` | number | The current timestamp.

  Source:
    - time/Time.js, line 215