# Timestamps

> Pearl's timestamp rules: at least 1 s after the parent, at most 5 minutes ahead of network time. Why WTEMA needs them, and where median time past still counts.

Source: https://pearlcodex.com/technical/difficulty/timestamps/ · Last updated: 2026-10-20 · Checked against Pearl's source code at v1.5.5

A block’s [timestamp](https://pearlcodex.com/glossary/#timestamp) is the miner’s word on when the block was made. Nobody can check it exactly: there is no clock everyone shares.

On Bitcoin a wrong timestamp matters much less, because difficulty looks at time only once every 2,016 blocks. On Pearl, difficulty moves after **every** block, using the gap between two timestamps. So Pearl needs rules that keep every gap positive and every lie small.

This page is about those rules and what they protect. How the 4 bytes are stored and decoded is on [time](https://pearlcodex.com/technical/block/time/).

## Try it

Fake some slow blocks and watch the target loosen, then see the next blocks pull it back.

_Interactive: WTEMA simulator. Try it on the page: <https://pearlcodex.com/technical/difficulty/timestamps/>_

## What are the rules?

A node accepts a block’s timestamp only inside this window:

| Field       | Size | Description                                                                                             |
| ----------- | ---- | ------------------------------------------------------------------------------------------------------- |
| Lower bound | —    | At least **1 second after the parent’s** timestamp. Anything earlier fails with `ErrTimeTooOld`.        |
| Upper bound | —    | At most **5 minutes** past the node’s network-adjusted time. Anything later fails with `ErrTimeTooNew`. |

Pearl’s own code was run on the edges: the parent’s second is rejected, parent + 1 s is accepted, the node’s adjusted time + 5 min 0 s is accepted, and + 5 min 1 s is rejected.

The upper bound is checked against the receiving node’s own idea of the time, so it can differ slightly from node to node. The lower bound depends only on the chain, so every node agrees on it.

## What is network-adjusted time?

Every node has its own clock, and some clocks are wrong. So a node uses [network-adjusted time](https://pearlcodex.com/glossary/#network-adjusted-time): its own clock, shifted by the median of the time differences its peers report when they connect. Offsets beyond ±70 minutes are ignored. This is btcd’s logic, unchanged.

## Why did Pearl drop the median rule?

Bitcoin only requires a block to be later than the [median time past](https://pearlcodex.com/glossary/#median-time-past) (MTP), the median of the previous 11 timestamps. That lets block times go backwards a little, and the gap between a block and its parent can be zero or negative.

That would break Pearl’s difficulty rule. [WTEMA](https://pearlcodex.com/glossary/#wtema) computes the next target from the parent’s solve time, t = its timestamp minus its own parent’s:

$$
X_{\text{next}} = X + \left\lfloor \frac{(t - 194) \cdot X}{604{,}800} \right\rfloor
$$

A negative t would be read as a block found impossibly fast. So Pearl requires t ≥ 1. The code comment says it plainly: the rule “is stricter than the original median-time rule and makes the median time check redundant. Required for WTEMA difficulty adjustment.”

It also caps how fast difficulty can climb: with t ≥ 1, one block can shrink the target by at most a factor of (1 − 193 ÷ 604,800) = 0.99968.

## Can a miner cheat with the clock?

Not by much. Here is why.

Each block multiplies the target by about (1 + (t − 194) ÷ 604,800). Over several blocks the factors multiply, and the gaps t add up. But the gaps telescope: their sum is just the newest timestamp minus the oldest. So, to a very good approximation, **the target after a run of blocks depends on the newest timestamp, not on the ones in between.** A lie in the middle is undone by the blocks after it, which must be stamped later still.

> **Scenario · made-up numbers: A 5-minute lie, three blocks later**
>
> From block 130,827’s bits, blocks really arrive every 194 seconds. One miner stamps its block 300 seconds late, so it looks like a 494-second block. The next honest block can’t go backwards: it is stamped 1 second after the lie, and the one after that 87 seconds later. Run through Pearl’s code:
>
> |                         | Honest timestamps | With the lie          |
> | ----------------------- | ----------------- | --------------------- |
> | Gaps on paper           | 194, 194, 194 s   | 494, 1, 87 s          |
> | Bits set by the 1st gap | `0x176af3a6`      | `0x176b013a` (easier) |
> | Bits set by the 2nd gap | `0x176af3a6`      | `0x176af87c`          |
> | Bits set by the 3rd gap | `0x176af3a6`      | `0x176af3a3`          |
>
> Two honest blocks later the lie has bought nothing. Thanks to rounding, the target is a hair smaller than the honest one.

The only timestamp that is never “undone” is the newest one, and the 5-minute rule limits it. Five minutes of fake lateness moves the next target by at most 300 ÷ 604,800, about 0.05%.

## Where does the median time past still matter?

In lock times. The rule for blocks changed; the rule for transactions did not. A transaction locked until a certain time becomes valid when the MTP of the last 11 blocks passes that time (BIP-113), and relative time locks (BIP-68) measure from the MTP too, exactly as in Bitcoin. See [locktime and sequence](https://pearlcodex.com/technical/transaction/locktime-and-sequence/).

On Pearl, the MTP has a neat shortcut. Every timestamp is later than its parent’s, so the last 11 are already in order, and their median is just the **6th newest**. At the normal pace that’s about 5 × 194 = 970 seconds, roughly 16 minutes, behind the newest block.

## What did launch look like?

Genesis is stamped 1,777,280,400: 2026-04-27 09:00:00 UTC. Blocks 1 to 5 followed at 1,777,280,401, …402, …403, …404 and …405: exactly one second apart, the minimum the rules allow.

At difficulty 1 that was all the time miners needed. Each 1-second block tightened the target by the largest step WTEMA allows, which is how difficulty began its climb. The full story is on [WTEMA](https://pearlcodex.com/technical/difficulty/wtema/).

**Make a guess:** Could a miner stamp a block 90 minutes in the future, which Bitcoin’s 2-hour rule allows?

**Answer:** No. Every node rejects it as too new.

Pearl’s limit is 5 minutes past network-adjusted time, so a node that receives a block stamped 90 minutes ahead fails it with `ErrTimeTooNew`. On Bitcoin, the same block would pass the time check.

> **Pearl vs Bitcoin**
>
> - **Lower bound:** Bitcoin requires a time later than the median of the previous 11 blocks, so times can step backwards. Pearl requires at least 1 second after the parent, so they never do.
> - **Upper bound:** Bitcoin allows 2 hours past network-adjusted time; Pearl allows 5 minutes.
> - **Lock times:** unchanged. Both use the median time past of 11 blocks.
> - **Why:** Bitcoin’s difficulty reads timestamps once per 2,016 blocks; Pearl’s reads them after every block.

**Code: the two checks and their parameters**

The lower bound, from [`validate.go`](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L686-L696), with `MinTimestampDeltaSeconds = 1` at [`line 26`](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L23-L26):

`node/blockchain/validate.go`

```go
prevTimestamp := time.Unix(prevNode.Timestamp(), 0)
minTimestamp := prevTimestamp.Add(time.Duration(MinTimestampDeltaSeconds) * time.Second)
if header.Timestamp.Before(minTimestamp) {
	return ruleError(ErrTimeTooOld, str)
}
```

The upper bound, from [`validate.go`](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L390-L396), with `MaxTimeOffsetMinutes: 5` in [`params.go`](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/chaincfg/params.go#L362) (regtest and simnet use 120):

`node/blockchain/validate.go`

```go
maxTimestamp := timeSource.AdjustedTime().Add(time.Minute * time.Duration(maxTimeOffsetMinutes))
if header.Timestamp.After(maxTimestamp) {
	return ruleError(ErrTimeTooNew, str)
}
```

The adjusted time comes from [`mediantime.go`](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/mediantime.go#L14-L30), and lock-time finality still uses `CalcPastMedianTime` in [`validate.go`](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L768-L781).

## In short

- Every block’s timestamp must be at least 1 second after its parent’s and at most 5 minutes past the node’s network-adjusted time.
- WTEMA turns each timestamp gap straight into the next target, so the gaps must always be positive and hard to fake.
- Lying about the time buys almost nothing: per-block nudges multiply together, so the target after several blocks depends mostly on the newest timestamp, and that one can’t run more than 5 minutes ahead.
- Because block times always increase, the median of the last 11 timestamps is simply the 6th newest. It still decides when time-locked transactions become valid, as in Bitcoin.
- At launch, blocks 1 to 5 came exactly 1 second apart: the fastest pace the rules allow.

## Read the code

- [MinTimestampDeltaSeconds = 1](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L23-L26) `node/blockchain/validate.go:23-26`
- [At least 1 s after the parent: ErrTimeTooOld](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L686-L696) `node/blockchain/validate.go:686-696`
- [At most 5 minutes ahead: ErrTimeTooNew](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L390-L396) `node/blockchain/validate.go:390-396`
- [MaxTimeOffsetMinutes: 5](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/chaincfg/params.go#L362) `node/chaincfg/params.go:362`
- [Network-adjusted time: peer offsets beyond ±70 minutes are ignored](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/mediantime.go#L14-L30) `node/blockchain/mediantime.go:14-30`
- [Lock times still use the median of the last 11 blocks](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L768-L781) `node/blockchain/validate.go:768-781`

## Sources

### Pearl source

- [Pearl source code at v1.5.5](https://github.com/pearl-research-labs/pearl/tree/v1.5.5)

### Bitcoin standards

- [BIP-113: Median time-past as endpoint for lock-time calculations](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki)
- [BIP-68: Relative lock-time using consensus-enforced sequence numbers](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)

### Chain data

- [Pearl Blockbook (block timestamps)](https://blockbook.pearlresearch.ai)
