[Ethereum] How to get the current time in Solidity


How can I get the current time in Solidity. I don't need the current block's time given by now and block.timestamp, but rather the actual current time.

Thank you for your help!

Best Answer

Within the Ethereum Virtual Machine, there isn't a way to get the current time, other than the block time. So there is no way to get it in Solidity.


There is disagreement between computers about what the current time is, and Ethereum needs to run every transaction with exactly the same outcome on every node.

What next?

Outline what you're trying to accomplish and ask about that.

  • Are you trying to time how long a transaction takes? Run the node locally and time it
  • Are you trying to achieve sub-block precision of payments? Payment channels might be what you're looking for
  • Trying to display a verified time in a Dapp? Use the local time, bounded by block timestamp
  • etc. etc.
Related Topic