<p>I think people look at the bitcoind log files to see the received times.  Possibly a grep on the log file might be what you need?</p>

CC BY-SA 3.0
2015-09-09T11:29:22.447Z
2015-09-09T11:48:03.483Z
2015-09-09T11:48:03.483Z
Louis
<p>What you probably want to do is set up a <code>-blocknotify=</code> script when you start your daemon. For example, you could echo the block hash with the <code>%s</code> formatter, and echo the time it was received, directing the output to a file:</p>

<pre><code>./bitcoind -daemon -server -blocknotify="echo %s; date"
</code></pre>

CC BY-SA 3.0
2015-09-09T13:14:39.370Z
2015-09-09T13:14:39.370Z
morsecoder
<p>No, there isn't.
<code>getblockcount</code> can only get the number of blocks in the best chain, but not the last received block.</p>

<p>You might need to write a new rpc to get the last received block. </p>

<p>First, add a new data structure in main.cpp and record blocks received order in <code>ProcessBlock()</code>.</p>

<p>Second, write a rpc to print out that data structure.</p>

CC BY-SA 3.0
2015-09-09T07:53:39.903Z
2015-09-09T07:53:39.903Z
mhchia
<p>If you mean the number of blocks in the entire chain, <code>getblockcount</code> gives you that.</p>

<p>The commands <code>getinfo</code> and <code>getblockchaininfo</code> also both contain "blocks" in their reply. The latter also includes "headers", which should show you a higher number than "blocks" when bitcoind has not caught up yet but has heard about a newer block.</p>

CC BY-SA 3.0
2015-07-09T08:24:01.560Z
2015-07-09T08:24:01.560Z
Jannes
<p>Is there a command to get the <code>DateTime</code> of when <code>bitcoind</code> last received a block?</p>

CC BY-SA 3.0
2015-11-08T16:37:30.457Z
This question was just pushed back to the frontpage. I've tried to rework it to make it as clear as possible and added some more tags. Please feel free to further edit or improve the post, or revert my changes if it isn't asking what you were interested in anymore. If it already has been answered to your satisfaction it would be helpful if you accepted an answer, so that it doesn't show up as "unanswered" anymore.
Murch
<bitcoind><json-rpc><block>
How can I get the DateTime of when bitcoind last received a block?
Haddar Macdasi
# How can I get the DateTime of when bitcoind last received a block?

(Asked by: username_0 on 2015-07-08)

Is there a command to get the `DateTime` of when `bitcoind` last received a block?

**Tags:** bitcoind, json-rpc, block

> **Comments:**
> **username_1**: This question was just pushed back to the frontpage. I've tried to rework it to make it as clear as possible and added some more tags. Please feel free to further edit or improve the post, or revert my changes if it isn't asking what you were interested in anymore. If it already has been answered to your satisfaction it would be helpful if you accepted an answer, so that it doesn't show up as "unanswered" anymore.  

---

## 4 answers

### Answer by username_2 on 2015-09-09. Score: 1

I think people look at the bitcoind log files to see the received times. Possibly a grep on the log file might be what you need?


---

### Answer by username_3 on 2015-09-09. Score: 1

What you probably want to do is set up a -blocknotify= script when you start your daemon. For example, you could echo the block hash with the %s formatter, and echo the time it was received, directing the output to a file:
./bitcoind -daemon -server -blocknotify="echo %s; date"


---

### Answer by username_4 on 2015-09-09. Score: 1

No, there isn't.
`getblockcount` can only get the number of blocks in the best chain, but not the last received block.

You might need to write a new rpc to get the last received block.

First, add a new data structure in main.cpp and record blocks received order in `ProcessBlock()`.

Second, write a rpc to print out that data structure.


---

### Answer by username_5 on 2015-07-09. Score: 0

If you mean the number of blocks in the entire chain, `getblockcount` gives you that.

The commands `getinfo` and `getblockchaininfo` also both contain "blocks" in their reply. The latter also includes "headers", which should show you a higher number than "blocks" when bitcoind has not caught up yet but has heard about a newer block.


---

