1

I want to run a function after every 365 days in Solidity. I have tried to use the now keyword, but it is not working (I tried in Remix).

How can I get the time?

Shane Fontaine
  • 18,036
  • 20
  • 54
  • 82
Himanshu
  • 11
  • 5

1 Answers1

0

You can use any of the built-in Solidity time units.

For example, you can do:

function f(uint start) public {
    if (block.timestamp >= start + 365 days) {
      // ...
    }
}
Shane Fontaine
  • 18,036
  • 20
  • 54
  • 82