network

timestamp

Every Bitcoin block contains a timestamp set by the miner. Timestamps anchor the blockchain in time, enable the difficulty adjustment, and were central to Satoshi Nakamoto's solution to the double-spend problem.

Every block in the Bitcoin blockchain contains a timestamp, a record of when the miner who created the block claims to have produced it. The timestamp is expressed as Unix time, the number of seconds elapsed since January 1, 1970. It is set by the miner and included in the block header before the proof-of-work calculation begins. While miners have some flexibility in setting the timestamp, the protocol enforces rules: a block's timestamp must be greater than the median of the previous eleven blocks, and nodes will reject blocks timestamped more than two hours in the future according to their own local clocks.

Timestamps serve a critical function in Bitcoin's difficulty adjustment mechanism. Every 2016 blocks, roughly every two weeks, the protocol compares the timestamps of the first and last block in the period to calculate how long it actually took to produce those blocks. If the actual time was less than two weeks, the difficulty increases; if it took longer, the difficulty decreases. This feedback loop keeps the average block interval close to ten minutes regardless of how much mining power enters or leaves the network.

Timestamps were also integral to Satoshi Nakamoto's solution to the double-spend problem. The whitepaper describes a distributed timestamp server: by including a cryptographic hash of the previous block in each new block, each block certifies the existence of all prior transactions at a particular point in time. This chain of timestamped blocks makes it computationally infeasible to rewrite history, because any alteration would invalidate the proof-of-work of every subsequent block.

Frequently asked questions

Can miners manipulate Bitcoin's timestamp?

Miners have limited ability to adjust the timestamp they include in a block. The Bitcoin protocol requires that a block's timestamp be greater than the median timestamp of the previous eleven blocks, and nodes on the network will reject blocks with timestamps more than two hours in the future relative to their own clocks. Within this window, miners can set a timestamp slightly ahead or slightly behind. This flexibility exists to accommodate clock differences across the network but does not allow meaningful manipulation of the difficulty adjustment.

How does the timestamp relate to Bitcoin's difficulty adjustment?

Every 2016 blocks, the Bitcoin protocol measures the elapsed time between the first and last block in that period using their timestamps. The target is for 2016 blocks to take exactly two weeks. If the measured time is shorter, meaning blocks were produced faster than intended, the difficulty increases. If it is longer, the difficulty decreases. This self-correcting mechanism ensures that new blocks are produced at an average rate of one every ten minutes regardless of changes in mining power.

What was Satoshi's timestamp server and why was it important?

In the Bitcoin whitepaper, Satoshi Nakamoto described Bitcoin's core structure as a distributed timestamp server. Each block timestamps a batch of transactions by including them in a block that references the cryptographic hash of the previous block. This creates an ordered chain in which the existence and ordering of every transaction is certified at a specific point in time by the computational work spent to produce that block. The timestamp server solves the double-spend problem by establishing an unforgeable ordering of events without requiring a central authority.