Being new to solidity, I find the docs on the Internet very confusing. I simply want to add 7 years to a

uint timeInSevenYearsFromNow = (block.timestamp).add(????);

What is the value of ???? and how do I calculate it ? Is it 220898482 ?

Yes, this is a noob question. I do not care how precise or exact it will be when executed, whether it is off by a nano-second or several minutes.

  • Do you care about leap seconds/years? Commented Jul 24, 2019 at 3:07
  • @TjadenHess not at all, I just want to express it all as digits, without using "days" or * operators... only a simple addition of numbers. Thanks ! Edit: thanks for the answer, but I am just curious about 220898482... Commented Jul 24, 2019 at 3:17
  • 1
    Why do you want to avoid days and *? It's more readable and adds zero cost since the constants get expanded out at compile time Commented Jul 24, 2019 at 4:32
  • I want to add a prime number, just for fun ;) Commented Jul 25, 2019 at 15:07

1 Answer 1


If you are OK with being overly simplistic and ignoring leap seconds and leap years, you can simply do

uint timeInSevenYearsFromNow = now + 7 * 365 days;

In older versions of solidity you could use years as a unit, but this was depreciated due to the complexity of accurately tracking time over long periods.

  • so is the 7*365 days actually 220898482 (or some other very close number) ? Commented Jul 24, 2019 at 3:16
  • 2
    Yes, the unit is just syntactic sugar for (365 * number of seconds in a day) Commented Jul 24, 2019 at 4:31
  • @TjadenHess How about it I cared about the leap seconds and leap years. How would I calculate this?
    – SirBT
    Commented Jan 31, 2022 at 16:06
  • @TjadenHess How would I go about this if I DID care about leap seconds and leap years?
    – SirBT
    Commented Jan 31, 2022 at 16:20

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.