> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cowboy.inc/llms.txt
> Use this file to discover all available pages before exploring further.

# std.clock

> The block height to arm a timer at for a block-time target

Timers fire at a block height, and block time is only estimated from it. `cowboy_sdk.std.clock` measures the chain's block rate in the actor's own storage as the actor runs, and turns a block-time target into the height to arm a timer at.

```python theme={null}
from cowboy_sdk import codec, runtime
from cowboy_sdk.std import calendar, clock

send_ms = calendar.next_at(runtime.get_timestamp_ms(), hour=7)
at = clock.height_at(self.storage, send_ms)
runtime.schedule_timer_ex(at, codec.encode({"kind": "daily", "at": at}))
```

* `height_at(storage, at_ms, max_blocks=MAX_TIMER_BLOCKS)` is at least the next block and at most `max_blocks` ahead. The default, 2,500,000, sits below the default timer TTL (`cip5.timer.max_ttl_blocks`, 2,592,000). The TTL is governed, so on a chain that lowers it, pass your own `max_blocks`. A target further out lands early.
* `ms_per_block(storage)` is the rate it uses. Until two calls at least `MEASURE_BLOCKS` (600) apart have measured it, the rate is `BLOCK_MS` (1,000). A measurement is clamped to 100 to 10,000 ms.
* The measurement is one storage key, `std.clock`, holding `[height, timestamp_ms, ms_per_block]`.

An estimate can land early or late. A handler whose work depends on the time itself compares `runtime.get_timestamp_ms()` with its target when the timer fires, and re-arms with `height_at` if it is early.

For a fixed period, `@every` and `runtime.schedule_after` already re-arm an early timer for you. Use `std.clock` for a calendar target, such as the next 07:00 UTC.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.