I want to run a session for a product in auction , my product struct contains the time interval we need for being the session of the bidding.

While initializing a product, I need to take the input of how much time interval they want their product to be in active bidding.

How can I take the inputs ?

1 Answer 1


All times in the blockchain are stored in Unix epoch format (How to calculate with time and dates?). The timestamp of execution can be retrieved with keyword now.

So basically you just need to convert your start/end dates into Unix epoch timestamps and then compare them to now.

You can also consider measuring elapsed time with block numbers (some developers prefer that method in the long run, for example https://ethereum.stackexchange.com/a/28472/31933) as the time interval between blocks is quite well known (although a bit inaccurately). But also some developers claim that timestamps are more accurate than block intervals (https://ethereum.stackexchange.com/a/24351/31933). You can decide for yourself.

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.