---
title: "Median Time Past (MTP) — definition | Nuri Glossary"
description: "The median timestamp of the last eleven blocks, used as the chain's consensus clock."
lang: "en"
type: "glossary-term"
canonical: "https://nuri.com/glossary/median-time-past"
---

# Median Time Past (MTP)

The median timestamp of the last eleven blocks, used as the chain's consensus clock.

## Basically

Median Time Past is how Bitcoin agrees on the time. It picks the middle time recorded in the previous 11 blocks.

## Key Takeaways

- Median Time Past (MTP) is Bitcoin's consensus clock. It calculates "current time" as the median block header timestamp of the previous 11 blocks, so the value always moves forward even when individual block timestamps are out of order.
- MTP prevents timestamp manipulation. A miner would need to control 6 of the last 11 blocks, over 50% of recent hashrate, to meaningfully shift MTP, making it far more resistant to gaming than a single block's timestamp.
- BIP 113 mandated MTP for all timelock evaluation. Since activation in July 2016, OP_CHECKLOCKTIMEVERIFY and OP_CHECKSEQUENCEVERIFY have both used MTP instead of raw block timestamps when enforcing time-based spending conditions.

## What Is Median Time Past?

Median Time Past (MTP) is the method Bitcoin uses to determine "current time" for consensus. It takes the timestamps from the previous 11 block headers, sorts them, and selects the middle value, the 6th in sorted order, instead of relying on any single clock or timestamp. That median becomes the network's agreed time reference.
Bitcoin is a decentralised system with no central time authority. Each node has its own local clock, and miners set their block timestamps manually, so one miner's timestamp could be inaccurate or deliberately manipulated. MTP combines multiple timestamps into one measure that resists tampering by any minority of miners.
Gregory Maxwell originally proposed the concept in 2013, and Thomas Kerin and Mark Friedenbach formalised it in BIP 113. It activated as part of the CSV soft fork deployment at block 419,328 on July 4, 2016.

## How It Works

The MTP calculation is straightforward. For any block in the chain, your node collects the timestamps from the 11 blocks immediately before it, sorts them in ascending order, and returns the middle value.
The window uses an odd number, 11, so the result is always a single, unambiguous value. The median also makes MTP monotonically increasing: adding a new block can keep MTP the same or push it forward, but never backward.

## Block Timestamp Rules

Bitcoin enforces two rules on the timestamp a miner places in a block header. Together, these constraints create a valid range for each block's timestamp.
Block timestamps do not need to be strictly ordered. Block N+1 can have an earlier timestamp than block N, as long as it exceeds MTP. Clock drift between miners causes this regularly, which is exactly why MTP exists as a stable reference.

## Why 11 Blocks?

The choice of 11 blocks aligns with Bitcoin's security model. At a target block time of 10 minutes, 11 blocks span roughly 110 minutes, and the odd number ensures the median is always a single value. The window is large enough that manipulating MTP requires majority hashrate control, at least 6 of 11 blocks, but small enough to keep MTP reasonably close to real wall-clock time, typically lagging by about one hour.

## Why Bitcoin Needs MTP

Bitcoin evaluated time-based nLockTime values against the timestamp of the block containing the transaction before BIP 113. A miner could set that timestamp up to 2 hours in the future, making time-locked transactions spendable earlier than intended.
Miners had a financial incentive to inflate timestamps, so this was not just a theoretical concern. Doing so let them include not-yet-mature time-locked transactions and collect their fees. Even a single dishonest miner with a small share of hashrate could accelerate timelocks by up to 2 hours at will.
MTP eliminates this attack vector. An attacker would need to have mined 6 of the last 11 blocks, requiring over 50% of recent hashrate, to shift MTP meaningfully; with just 1% of hashrate, the expected wait to solve 6 of 11 consecutive blocks exceeds 43,000 years. Even with 50% hashrate, solving 6 consecutive blocks has a probability of 1/64 and happens only roughly every 12 hours, and the maximum shift is still bounded by the 2-hour future limit on individual timestamps.

## Absolute Timelocks (OP_CHECKLOCKTIMEVERIFY)

OP_CHECKLOCKTIMEVERIFY (CLTV), defined in BIP 65, makes a transaction output unspendable until a specific point in time. For time-based locks rather than block height locks, CLTV compares the transaction's nLockTime with the block's time reference. Since BIP 113, that reference is MTP rather than the block's own timestamp.
The threshold between height-based and time-based interpretation is 500,000,000. Values of nLockTime below this threshold are treated as block heights, while values at or above it are treated as Unix timestamps evaluated against MTP.

## Relative Timelocks (OP_CHECKSEQUENCEVERIFY)

OP_CHECKSEQUENCEVERIFY (CSV), defined in BIP 112, enforces relative timelocks: an output cannot be spent until a certain amount of time has elapsed since it was confirmed on-chain. For time-based relative locks, the nSequence field specifies the delay in multiples of 512 seconds.
The elapsed time is measured from the MTP of the block before the one containing the output being spent. CSV was deployed at the same time as BIP 113, so it has always used MTP as its time reference.

## Lightning Network Channels

Lightning channels rely heavily on timelocks enforced by CLTV and CSV. When a channel is force-closed, the party broadcasting the commitment transaction must wait through a CSV-enforced delay before claiming their funds. Measured against MTP, this delay gives the counterparty time to broadcast a penalty transaction if an outdated state was published, and MTP ensures miner timestamp manipulation cannot bypass these time-based security guarantees.
CLTV and CSV interact in practice to enforce these channel delays. See the research article on Bitcoin timelocks for a deeper look at how they work together.

## Time-Locked Contracts

Hash Time-Locked Contracts (HTLCs), Discreet Log Contracts (DLCs), and other conditional payment schemes use timelocks as refund mechanisms. If one party fails to act within the time window, the other party can reclaim funds after the timelock expires. MTP is the clock for these deadlines, so all nodes enforce them consistently regardless of their local system time.

## MTP and Soft Fork Activation

BIP 113 activated as part of a combined deployment alongside BIP 68, which introduced consensus-enforced sequence number relative locks, and BIP 112, which introduced CSV. The deployment used BIP 9 versionbits signalling on bit 0.
Miners signalled support in 1,946 of 2,016 blocks during the signalling window from blocks 415,296 to 417,311, reaching 96.53%. Support far exceeded the 95% threshold. The deployment locked in at block 417,312 on June 21, 2016, and activated at block 419,328 on July 4, 2016.
Time-locked transactions needed approximately one additional hour before confirmation after activation, since MTP lags behind real time by roughly that amount. The security improvement was considered worth this trade-off.

## MTP Lag

MTP is the median of the last 11 blocks, which span roughly 110 minutes at the target block time, so it typically lags behind real wall-clock time by about one hour. Time-locked transactions therefore become spendable slightly later than a simple wall-clock calculation would suggest. Applications and wallets that set time-based locks should account for this lag when choosing lock times.

## Time Warp Attack

An attacker controlling over 50% of hashrate could theoretically manipulate timestamps to affect the difficulty adjustment algorithm in a "time warp attack". By setting block timestamps just 1 second above MTP, the attacker could make a 2,016-block retarget window appear to have taken far longer than it actually did and trigger difficulty reductions of up to 75% per period, the maximum allowed adjustment. The attack would require sustained majority hashrate, making it impractical against Bitcoin's current network, and the Great Consensus Cleanup proposal includes a fix for this vulnerability.

## Timestamp Ordering Assumptions

Developers building on Bitcoin should not assume block timestamps are strictly ordered. Block N+1 can have an earlier timestamp than block N, so any application logic that depends on time should use MTP, which is monotonically increasing, rather than individual block timestamps. The Bitcoin Core reference implementation provides a GetMedianTimePast() method for this purpose.

## Year 2106 Limit

Bitcoin stores block timestamps as unsigned 32-bit integers, which overflow around the year 2106. This avoids the more immediate Year 2038 problem, which affects signed 32-bit integers, but will eventually require a protocol change. It is a known long-term consideration rather than an immediate risk.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.
Part of the [Nuri glossary](https://nuri.com/glossary), which defines 1876 Bitcoin, Lightning, wallet, stablecoin and payment terms.
