<p>Transactions do not have an individual timestamp. The closest you can do is get the timestamp from the block that it was included in (but note Pieter's warning about accuracy).</p>

<h1>API Example</h1>

<p>Using blockchain.info, for example you can do:</p>

<p><code>https://blockchain.info/rawtx/$tx_hash</code></p>

<p>For <code>$tx_hash = b6f6991d03df0e2e04dafffcd6bc418aac66049e2cd74b80f14ac86db1e3f0da</code> this would return:</p>

<pre><code>{
    "hash":"b6f6991d03df0e2e04dafffcd6bc418aac66049e2cd74b80f14ac86db1e3f0da",
    "ver":1,
    "vin_sz":1,
    "vout_sz":2,
    "lock_time":"Unavailable",
    "size":258,
    "relayed_by":"64.179.201.80",
    "block_height: 12200,
    "tx_index":"12563028",
    "inputs":[


            {
                "prev_out":{
                    "hash":"a3e2bcc9a5f776112497a32b05f4b9e5b2405ed9",
                    "value":"100000000",
                    "tx_index":"12554260",
                    "n":"2"
                },
                "script":"76a914641ad5051edd97029a003fe9efb29359fcee409d88ac"
            }

        ],
    "out":[

                {
                    "value":"98000000",
                    "hash":"29d6a3540acfa0a950bef2bfdc75cd51c24390fd",
                    "script":"76a914641ad5051edd97029a003fe9efb29359fcee409d88ac"
                },

                {
                    "value":"2000000",
                    "hash":"17b5038a413f5c5ee288caa64cfab35a0c01914e",
                    "script":"76a914641ad5051edd97029a003fe9efb29359fcee409d88ac"
                }

        ]
}
</code></pre>

<p>From there you can query the block height of the inputs the same way as above using the <code>inputs[i].prev_out.hash</code> field. Then, to get the timestamp for a block, just query the raw block by height. E.g. for the output timestamps, you would use <code>block_height: 12200</code> for the example above:</p>

<p><code>https://blockchain.info/block-height/12200?format=json</code></p>

<p>The timestamp would be returned in <code>blocks[0].time</code></p>

<p><strong>Note</strong>: Transactions technically can have an individual timestamp. When they do, it is the <code>locktime</code> property, see <a href="https://en.bitcoin.it/wiki/Transaction" rel="nofollow noreferrer">Bitcoin Wiki - Transaction</a>. However, the <code>locktime</code> is most likely not going to be the time that it was created, rather, the time it is available for spending: </p>

<blockquote>
  <p>if non-zero and sequence numbers are &lt; 0xFFFFFFFF: block height or
  timestamp when transaction is final</p>
</blockquote>

CC BY-SA 4.0
2018-07-24T13:52:06.447Z
2018-07-24T13:52:06.447Z
JBaczuk
<p>I have a transaction ID and I need to get the time of input and the of output of that transaction (Unix timestamp) programatically using a block explorer or any API.</p>

<p>Is this possible ? If so how can I do that ? </p>

CC BY-SA 4.0
2018-07-24T13:51:07.703Z
Transactions don't have a time. You can look up the timestamp of the block it was included in (which itself may be minutes to an hour off of the real time it was created).
Pieter Wuille
<blockchain.info>
How to get time of input and output of a given a transaction?
Kwago
# How to get time of input and output of a given a transaction?

(Asked by: username_0 on 2018-07-24)

I have a transaction ID and I need to get the time of input and the of output of that transaction (Unix timestamp) programatically using a block explorer or any API.

Is this possible ? If so how can I do that ?

**Tags:** blockchain.info

> **Comments:**
> **username_1**: Transactions don't have a time. You can look up the timestamp of the block it was included in (which itself may be minutes to an hour off of the real time it was created).  

---

## 1 answers

### Answer by username_2 on 2018-07-24. Score: 1

Transactions do not have an individual timestamp. The closest you can do is get the timestamp from the block that it was included in (but note Pieter's warning about accuracy).
API Example
Using blockchain.info, for example you can do:
https://blockchain.info/rawtx/$tx_hash
For $tx_hash = b6f6991d03df0e2e04dafffcd6bc418aac66049e2cd74b80f14ac86db1e3f0da this would return:
{
    "hash":"b6f6991d03df0e2e04dafffcd6bc418aac66049e2cd74b80f14ac86db1e3f0da",
    "ver":1,
    "vin_sz":1,
    "vout_sz":2,
    "lock_time":"Unavailable",
    "size":258,
    "relayed_by":"64.179.201.80",
    "block_height: 12200,
    "tx_index":"12563028",
    "inputs":[


            {
                "prev_out":{
                    "hash":"a3e2bcc9a5f776112497a32b05f4b9e5b2405ed9",
                    "value":"100000000",
                    "tx_index":"12554260",
                    "n":"2"
                },
                "script":"76a914641ad5051edd97029a003fe9efb29359fcee409d88ac"
            }

        ],
    "out":[

                {
                    "value":"98000000",
                    "hash":"29d6a3540acfa0a950bef2bfdc75cd51c24390fd",
                    "script":"76a914641ad5051edd97029a003fe9efb29359fcee409d88ac"
                },

                {
                    "value":"2000000",
                    "hash":"17b5038a413f5c5ee288caa64cfab35a0c01914e",
                    "script":"76a914641ad5051edd97029a003fe9efb29359fcee409d88ac"
                }

        ]
}

From there you can query the block height of the inputs the same way as above using the inputs[i].prev_out.hash field. Then, to get the timestamp for a block, just query the raw block by height. E.g. for the output timestamps, you would use block_height: 12200 for the example above:
https://blockchain.info/block-height/12200?format=json
The timestamp would be returned in blocks[0].time
Note: Transactions technically can have an individual timestamp. When they do, it is the locktime property, see Bitcoin Wiki - Transaction. However, the locktime is most likely not going to be the time that it was created, rather, the time it is available for spending: 

if non-zero and sequence numbers are < 0xFFFFFFFF: block height or
  timestamp when transaction is final


---

