How can I calculate how long it took a transaction to be confirmed? Is it possible to calculate - or even reasonably estimate - how long it took for a transaction to be included in a block after it was first created?

I'm asking about already confirmed transactions which are already included on the blockchain - and all transactions - not just ones that belong to me.

I am currently building a project which scrapes a given blockchain for whatever info/attributes a user desires. You can check it out here - be warned it's no where near ready for production and not even at version 1 yet - but the develop branch is getting close.

As I understand from the docs and the answer to this question the time received attribute is not, as some may think, the time a transaction was "received into a block" but rather the time when my client first noticed the transaction - this attribute is also not available when using getrawtransaction. So that's a no-go.

Ideally, I'm looking for the time that a transaction is created (sent) and the time it is included (confirmed) on a block.

Based on the above info my idea is:


for new (unconfirmed) transactions we record the time that my node
first notices the transaction
then we record the time that my node
notices it is confirmed


This would at least give me an indication as to how long it takes newly created transactions to be confirmed. Of course latency adds a huge amount of noise here, but it's at least a step in the right direction!

I would like to do this for existing, confirmed transactions if possible.

Thanks for your time.
Unfortunately, at least for bitcoin and litecoin (and likely most bitcoin derivative block chains), the only way to get this information is to have a node/client listening at the time the transaction appears on the network.

Otherwise your client will simply use the block's timestamp for each transaction. 

This design means that getting this information is only possible if using a third party who was maintaining a copy of the blockchain at that time, or potentially getting a dump of a trusted source's blockchain which should (I believe, although I haven't tested it myself) maintain the original client's timestamps. 

Would be great if someone could confirm this. I will myself if I get the chance to test it but that might not happen any time soon.