I'm using Bitcoin Core CLI to get block info:

.\bitcoin-cli.exe getblockchaininfo

Among other things, this returns two items:

  "time": 1713464903,
  "mediantime": 1713461780,

I understand the mediantime is the median of the time value for the past 11 blocks, and is used as a check to ensure the miner used a valid timestamp value for the time of the block they just mined.

If I add 50 minutes to that mediantime value, is that a reasonably good proxy for when the most recently mined block would have been mined? Intra block time is designed to be 10 minutes, but varies because of difficulty and the unpredictable nature of hashing, so of course it won't be exact.

I'm using the following in Powershell to display the most recently mined block number, along with the time it was mined, and when it was expected to be mined, just for my own edification:

[System.String]$block_chain_info = (.\bitcoin-cli.exe --datadir=E:\BitcoinCore\Data getblockchaininfo);
If ($block_chain_info -ne $null)
    [System.Object]$bci = (ConvertFrom-Json $block_chain_info -ErrorAction SilentlyContinue);
    $epoch = New-Object DateTimeOffset(1970,1,1,0,0,0,0);
    $block_time = $epoch.AddSeconds($bci.time);
    #mediantime is the median time of the past 11 blocks
    $block_expected_time = $epoch.AddSeconds($bci.mediantime + (50 * 60));
    Write-Output "Current Block Number is:    $($bci.blocks)";
    Write-Output "Block Time is:              $($block_time.LocalDateTime.ToString{s})";
    Write-Output "Block Expected Time is:     $($block_expected_time.LocalDateTime.ToString{s})";
    "Could not obtain block chain info from the Bitcoin Core CLI";

I'm in the Central Standard Time timezone, so for the most recent block, it shows:

Current Block Number is:    839816
Block Time is:              2024-04-18T13:46:27
Block Expected Time is:     2024-04-18T13:33:41

In case it matters, my bitcoin-cli --version is:

Bitcoin Core RPC client version v27.0.0
Copyright (C) 2009-2024 The Bitcoin Core developers


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.