5

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!

  • you mean, current System time? – Gopal ojha Aug 2 '17 at 0:03
20

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.

Why?

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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