Current date/time in smart contract

Hi Everyone,

Iā€™m developing a smart contract which logic depends on current date/time. Basing on its value the contract should allow/disallow certain actions (for instance a user should be allowed to withdraw a balance no more than once per week). For this case it should identify current date/time when the transaction is processing. Pls advise what is the best way to do this? Any examples would be great.

Thanks in advance,
Alex

Hi Alex,

You can get the timestamp of the latest block though there is no guarantee of the accuracy at the moment so be careful how you use it:

1 Like