This article was translated from Japanese with AI. Read the original (日本語) · Report a translation issue

Every Bitcoin block records a time, known as its timestamp.

Many people probably picture the timestamp as an accurate time stamped automatically. In reality, it is a self-reported value that the miner writes in. That means it isn't an absolutely accurate time, and occasionally a newer block even carries an earlier time than an older one.

If timestamps are self-reported, that raises the question of whether they could be used for some kind of cheating, or whether time could run backward. In Bitcoin, a distributed ledger, "time" is a crucial concept because it ties into both transfers and holdings.

In fact, Bitcoin builds two conditions into its timestamps. Together, these two conditions keep timestamps consistent without any centrally managed clock.

This article explains what the two timestamp conditions are and why they were designed that way. It also covers the "time warp attack," a niche attack that exploits these timestamp conditions. Understanding how timestamps work will deepen your understanding of how Bitcoin handles time.

Examples of block timestamps going backward

A Bitcoin timestamp is a value that the miner who mined the block can set themselves. Miners sometimes set a timestamp slightly in the future relative to the actual time, and as a result, the chronology of timestamps can run backward relative to the order of the blocks.

Here are some real examples, which you can check on mempool.

mempool: Block 843880

In rarer cases, a timestamp can even point to a later time than the next two blocks.

mempool: Block 825453

Since mining a single Bitcoin block takes about 10 minutes, cases like these are unusual, but they have cropped up from time to time.

Even when a timestamp runs backward, however, the order of the blocks and the block height themselves remain valid, because the rules of computation require each block to be built on the information in the previous one. The timestamp is merely supplementary data for knowing the approximate time, and the two conditions explained below ensure it causes no problems.

A timestamp running backward is also a striking sight for people who don't know about this, and those who spot one are often surprised enough to post about it on social media, where it gets attention. The examples above were picked from ones that drew attention on X.

Admittedly, if you don't know about it, you'd suspect that either the mempool site is broken or Bitcoin is.

Such posts get a fair amount of attention, and without fail Bitcoin enthusiasts gather to explain the relationship between timestamps and blocks. The next section covers the two timestamp conditions that often come up in their explanations.

The two timestamp conditions

Bitcoin timestamps are subject to two conditions.

  • Condition 1 (lower bound): must be greater than the median of the previous 11 blocks
    • timestamp > MTP
  • Condition 2 (upper bound): must be no more than 2 hours ahead of network-adjusted time (the median of connected nodes' times)
    • timestamp < NetworkTime + 2h

Every full node checks both conditions, but the two carry different weight.

"Condition 1 (lower bound): > MTP" is a rule under which a violating block is permanently invalid, and checking for violations is easy.

"Condition 2 (upper bound): within +2 hours," on the other hand, depends on the node's local time, so a block rejected as a violation now may be judged valid if rechecked later. For this reason, Bitcoin Core's implementation does not record a Condition 2 violation as a "permanently invalid block."

Let's look at each condition in detail.

Condition 1: must be greater than the median of the previous 11 blocks

Condition 1 is the rule that a block's timestamp must be greater than the median of the previous 11 blocks' timestamps, known as the Median Time Past (MTP).

timestamp > MTP

Calculating the MTP is simple. Take the timestamps of the previous 11 blocks, sort them in ascending order, and use the value right in the middle (the 6th). If the reference were just the previous block rather than the MTP, a block whose timestamp was set far into the future would leave subsequent blocks unable to exceed it for a long time.

Using the median rather than the mean also means one or two outliers have no effect. And because the median is taken over an odd number of blocks, 11, there's no need to average any times; simply taking the 6th value keeps things simple.

The MTP can be derived mechanically from on-chain data alone. So whether a given block violates the MTP rule comes out the same no matter who checks it or when. A violating block is treated as permanently invalid on the spot.

Condition 2 (upper bound): must be within network-adjusted time + 2 hours

Condition 2 is the rule that a block's timestamp must not be 2 hours or more into the future relative to network-adjusted time.

timestamp < NetworkTime + 2h

The difference from Condition 1 is that the criterion depends not on on-chain data but on the local time of the node doing the checking.

Network-adjusted time is your own system clock corrected by the median time offset from your connected peers, so it differs from node to node and depending on when the check is made.

So while a block that violates Condition 2 is rejected on the spot, unlike other violations (such as invalid signatures or insufficient proof of work), it isn't permanently recorded as a block fully excluded from the network. Once real time passes and catches up with the timestamp, the block may be judged valid and accepted if it's checked again later.

In Bitcoin Core's implementation, too, a Condition 2 violation is not recorded as a "permanently invalid block." The difference is that Condition 1 is an absolute standard that can't be reversed once violated, while Condition 2 is merely a temporary hold saying "too early for now."

The MTP and the two timestamp conditions support several features in Bitcoin. Here are two of them.

1. Preventing timelocks from being unlocked early

nLockTime and OP_CHECKLOCKTIMEVERIFY (CLTV) are features that treat a transaction as invalid until a specified point (a block height or a time) is reached. Since BIP113 (the MTP proposal) in 2016, time-based locks have been evaluated against the MTP rather than the timestamp.

If the timestamp were used, a miner could push it up to 2 hours ahead in their own block, making transactions spendable early that shouldn't be usable yet. On the other hand, because the MTP is the median of 11 blocks, it lags real time by about 50–60 minutes on average, with the side effect that transactions become valid a little later.

2. Preventing manipulation of the difficulty adjustment

Through Bitcoin's difficulty adjustment, mining difficulty is retuned roughly every two weeks so that blocks are produced about once every 10 minutes.

The difficulty adjustment is calculated from the difference between the first and last timestamps of a 2,016-block period (the elapsed time, with a target of 20,160 minutes). By pushing the first and last timestamps of a period in opposite directions, miners can stretch or shrink the elapsed time, but Conditions 1 and 2 limit how far they can shift it per period to at most 180 minutes (−60 to +120 minutes), an effect of only about 0.89% relative to 20,160 minutes.

That said, this applies only when manipulating the blocks at either end of the period. If a miner with a majority of the hashrate can mine more than half the blocks in the period, they can carry out an attack that exploits the median in Condition 1 to hack the difficulty adjustment (see the time warp attack below).

Still, it requires mining the first and last blocks of every period, and the probabilistic difficulty and cost of doing so are considerable.

Why are the timestamp conditions so loose?

brown wooden framed analog clock

As explained above, the allowable window for timestamps is roughly "about −60 to +120 minutes," which is by no means narrow and could even be called loose. The easiest way to understand why it's this loose is to consider what would happen if it were made strict.

The world's clocks are out of sync to begin with

Computer clocks on the internet are not nearly as tightly synchronized as we tend to think. Even when synced via NTP (Network Time Protocol), they drift by anywhere from a few hundred milliseconds to several seconds, and the lag as a block propagates to nodes around the world also contributes to time discrepancies.

Time itself is a human construct, and even "absolutely accurate time" can be seen as artificial. The more precise the time you demand, the more you need someone to decide what time it is, which centralizes timekeeping and could end up creating a single point of failure. That opens the door to unexpected failures, such as when someone gains an incentive to manipulate the time, or when the timekeeper goes offline.

So Bitcoin doesn't depend on any external source of time; instead, each miner stamps a timestamp and each node verifies it. In Bitcoin, the timestamp is supplementary data, and it's block height that serves as the true clock of the Bitcoin world and defines its chronology.

The risks of a stricter timestamp window

If the timestamp window were narrowed to, say, 10 minutes, blocks would be rejected frequently, whether because a node's network-adjusted time was off by 10 minutes, because of block propagation delays on poor connections, or even because of daylight saving time shifts.

The result would be a situation where some nodes reject a block and others accept it, hurting propagation across the network and making Bitcoin less usable. And since a miner whose clock was off would see their blocks rejected and their work wasted, miners would need to make separate investments to stay synced to accurate time.

Narrowing the timestamp window would end up excluding honest nodes and miners whose only fault is a slightly-off clock. That in turn risks centralization around large miners who can afford to invest in setups that obtain accurate time.

💡
That said, I personally feel the 180-minute window is long, so I looked into why that figure was chosen. According to the page below: "They're 'good enough' values that Satoshi chose when they coded the first version of bitcoin."
It's a setting even Bitcoin Core developers find curious, but perhaps the thinking is that since it has caused no problems in practice, there's no need to change it.
https://learnmeabitcoin.com/technical/block/time/
the two hour rule is really weird. it's the only 'consensus' rule that isn't based on blockchain data but on local data
John Newbery, Bitcoin Core PR Review Club (Jun 19, 2019)

Proof of stake (PoS) and proof of work (PoW) treat time in opposite ways

In proof-of-work Bitcoin, timestamps are flexible, whereas proof of stake divides time in advance into evenly spaced slots, and the party responsible for each slot (a validator) is chosen beforehand by lottery.

In proof of work, the block comes first and real-world time follows, while in proof of stake, time is fixed first and block production follows, so the two take opposite approaches to time.

For example, for running a validator on Ethereum, which advances one block every 12 seconds, syncing to public NTP servers such as Google, Ubuntu and the NTP Pool is recommended in practice (reference), and clock drift creates the risk of missing the timing for block proposals and attestations and losing out on revenue.

So proof of stake only works with human-world time as a given, and can be seen as structurally forced to rely on "accurate time."

The looseness of timestamps does come at a price, however, and the next section explains the "time warp attack."

The time warp attack: abusing the median, a defense against outliers

The median used in Condition 1 has the positive property of not being affected by one or two outliers. But for a miner with a majority of the hashrate, that very property of ignoring outliers becomes a way to hack the difficulty adjustment. The attack that exploits the MTP (median) is called the "time warp attack."

The time warp attack advances block timestamps by one second at a time and sets only the final block of each difficulty adjustment period to the current time, driving difficulty down at an accelerating pace until, in theory, it reaches 1 in about 39.5 days.

However, carrying out a time warp attack requires control over the median of the past 11 blocks, which means sustaining a majority of the hashrate. It is therefore an attack that could be carried out alongside a 51% attack.

The figure below gives a concrete picture.

Time warp attack diagram

Once the time warp attack begins, each block is stamped just one second after the last, even if it actually took 10 minutes to mine, and only the final block of each difficulty adjustment period is set back to the current time. Because time jumps to the present only at the final block, it's called a "time warp attack."

Period Reported time of first block Reported time of last block (actual time) Next difficulty
Period 1 Week 0 (normal) Week 2 ×1
Period 2 Nearly week 0 Week 4 ×1/2
Period 3 Nearly week 0 Week 5 ×2/5
Period 4 Nearly week 0 Week 5.4 ×2/5.4

Period 1 is normal, but because every block except the last advances by one second, the reported time advances only about 33 minutes even over 2,016 blocks. As a result, from period 2 onward the measured elapsed time totals 4 weeks, and difficulty begins to plummet.

In period 3 the difficulty is halved, so in reality a block is mined every 5 minutes. In other words, 2,016 blocks are used up in a single week. Period 4 takes 2.8 days, period 5 one day, and the pace keeps accelerating as difficulty keeps falling.

At block 960,205 the difficulty is about 126 trillion, yet in theory it would fall to 1 in about 39.5 days.

💡
There is a limit that a single difficulty adjustment can lower difficulty by at most a factor of 4 (0.25x), but this limit is never hit.
Because the actual elapsed time converges, the adjustment multiplier also converges to roughly 0.357x.
Difficulty adjustment periods and real time

As for what an attacker would gain from a time warp attack, the prize is the coinbase rewards still remaining in Bitcoin. As of August 2026, roughly 930,000 BTC remain unissued.

However, difficulty falls for other miners too, so the attacker can't take everything. Moreover, once difficulty drops to 1, small miners or even home PCs might be able to mine blocks, which would likely both shrink the attacker's profits and make it harder to probabilistically maintain control of the MTP.

Of course, the bar for this attack is high. Anyone can see blocks advancing one second at a time, and sustaining more than 51% for over a month would be enormously expensive.

A fix for the time warp attack is currently under discussion as BIP54, "Consensus Cleanup." BIP54 proposes that the first block of a period must not be more than 2 hours earlier than the last block of the previous period. It's a niche attack that exploits the nature of timestamps, but it's interesting as an issue that has remained open for years.

Summary: blocks are time, and timestamps are supplementary data

Bitcoin timestamps are self-reported by miners and stamped into blocks. This article covered examples of time running backward as well as the two timestamp conditions.

It also explained why Bitcoin's timestamps are loose, and walked through the time warp attack, an unresolved attack that exploits timestamps.

In the Bitcoin world, block height is what defines the on-chain chronology, and the timestamp is merely supplementary data for reference. It feels as though the design deliberately avoids treating the human-made concept of time as absolute.

Even so, it's thanks to timestamps that the difficulty adjustment works and keeps Bitcoin in step with our real-world clocks. Knowing the rules for timestamps gives you a chance to reflect on how time is handled technically, and on just how important the concept of "time" is.