---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.3
alternate:
  - https://divkit.tech/docs/en/concepts/timer.md
  - https://divkit.tech/docs/ru/concepts/timer.md
---
> **Documentation Index:** Fetch the complete configuration index at https://divkit.tech/docs/en/llms.txt

# Timers

You can calculate time using [timers](https://divkit.tech/docs/en/concepts/divs/2/div-timer.md). They can measure time as well as trigger actions at set intervals or when the timer stops.

## Timer properties

- `id`: Timer ID. Required field.
- `duration`: Timer period in milliseconds. If set to `0` or not set, the timer continues running indefinitely until the stop event is triggered.
- `tick_interval`: Interval between timer ticks. The actual tick rate may differ from the specified value by a few milliseconds: we deliberately made it so that the variable stores the actual time that's not rounded up or down.
- `value_variable`: Variable that stores the current timer value. It's updated every tick. This value reflects actual elapsed time, so it may not always be a multiple of `tick_interval` and may include additional milliseconds after the last tick.
- `tick_actions`: Array of [actions](https://divkit.tech/docs/en/concepts/divs/2/div-action.md) to execute on each timer tick.
- `end_actions`: Array of [actions](https://divkit.tech/docs/en/concepts/divs/2/div-action.md) to execute when the timer stops.

 Timers are declared in the `card` object:

```json translate=no
{
  "templates": {...},
  "card": {
    "timers": [
      {
        "id": "ticker",
        "duration": "@{timer_duration}",
        "tick_interval": "@{timer_interval}",
        "value_variable": "timer_value",
        "tick_actions": [],
        "end_actions": []
      }
    ],
    ...
  }
}
```
## Controls

To control a timer from the layout, use the following [actions](https://divkit.tech/docs/en/concepts/interaction.md):

#|
||
**Action**
|
**Description**
||
||
`div-action://timer?id=timer_id&action=start`
|
Start the timer.
||
||
`div-action://timer?id=timer_id&action=stop`
|
Stop the timer and execute `end_actions`.
||
||
`div-action://timer?id=timer_id&action=pause`
|
Pause the timer.
||
||
`div-action://timer?id=timer_id&action=resume`
|
Resume the timer.
||
||
`div-action://timer?id=timer_id&action=cancel`
|
Interrupt the timer. `value_variable` doesn't change and retains its last saved value.
||
||
`div-action://timer?id=timer_id&action=reset`
|
Restart the timer (runs `cancel`, then `start`).
||
|#

{% cut "View an interactive example" %}


<iframe src="https://yastatic.net/s3/home/divkit/docs/1.0.8/index.html?url=https://yastatic.net/s3/home/divkit/doc_samples/common/timer_1.json" width="700" height="500" frameborder="1"></iframe>


{% endcut %}

<!-- source: en/_includes/index/troubleshooting.md -->
## Learn more {#troubleshooting}

You can discuss topics of interest in the DivKit user community in Telegram: [https://t.me/divkit_community_en](https://t.me/divkit_community_en).



[DivKit Repository](https://github.com/divkit/divkit)
<!-- endsource: en/_includes/index/troubleshooting.md -->
