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