Difficulty Adjustment changes the acceptable hash threshold, not transaction count or subsidy. A smaller target makes searching harder; consensus uses the nBits target while difficulty expresses a ratio.
Mainnet calculates a new target at heights divisible by 2,016 and otherwise carries forward nBits. Two weeks means a target duration of 1,209,600 seconds, not a calendar deadline. A sudden hashrate outage therefore triggers no immediate emergency adjustment. [Bitcoin Core v29.0: retarget] [Bitcoin Core v29.0: network parameters]
Bitcoin Core subtracts the first block’s header time from the last in the completed period. There are 2,015 gaps between 2,016 blocks; the calculation preserves this historical detail. These are miner-chosen header times within allowed limits, not exact discovery measurements or Median Time Past. [Bitcoin Core v29.0: retarget] [Bitcoin Core v29.0: network parameters]
Observed time is clamped between one quarter and four times the target duration. The old target is multiplied by this time and divided by target duration; the result is capped at powLimit and compactly encoded. Faster periods lower the target and raise difficulty; slower ones do the opposite. [Bitcoin Core v29.0: retarget] [Bitcoin Core v29.0: network parameters]
Adjustment aims for a ten-minute average at a given hashrate, not scheduled individual blocks. It stabilizes neither BTC price, miner profit nor daily transaction count. Post-adjustment hashrate changes and randomness still affect discovery times; payout rules and halving operate separately. [Bitcoin Core v29.0: retarget] [Bitcoin Core v29.0: network parameters]
Use your node to obtain boundary-block times and bits from the last old and first new blocks. Reconstruct numerical targets, time clamping and compact rounding. A website’s percentage estimate is insufficient: it changes before the period ends, and test networks may follow other rules. [Bitcoin Core v29.0: retarget] [Bitcoin Core v29.0: network parameters]
For the clearest picture, read this entry together with Proof of Work, Mining, Timechain, Block Subsidy. The reverse links also lead from Timechain, Proof of Work, Mining, Halving.