In a function, does block.timestamp record the time the transaction was processed, or the time the block.timestamp computational step was processed?

Is block.timestamp the time the transaction is processed, or would time and time2 differ ?

function doSomething() {

uint time = block.timestamp

// ... a few 400000 gas of other things ... //

uint time2 = block.timestamp


3 Answers 3


As per the documentation you will find

timestamp of the current block in seconds since the epoch

so you have a single timestamp (when it is created) per block therefore time1=time2

read more about timestamp at Is the block.timestamp value in Solidity seconds or milliseconds?


In reference to your comment about transaction timestamps, the timestamps of all transactions in a block are the same.

There can be many transactions in a block, all have the same timestamp, and all are the same timestamp as the block's.


block.timestamp is the value what miner decides to publish there when he or she finds a block.

It is subject to some interpretation and can be skewed, though only for a while. In practice this is not a real problem and risks of using block number are often higher.

How would a miner cope with a huge block time?

How does Ethereum avoid inaccurate timestamps in blocks?


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.