I'd like to describe time like Apr15th 10:00AM . I know how to describe time range as follows, but I am not sure how to call date of time. Could you tell me about it if you know?

1 == 1 second
1 minutes == 60 seconds
1 hours == 60 minutes
1 days == 24 hours
1 weeks = 7 days
1 years = 365 days

15 April 2016 10:00 UTC translates to 1460714400 in Unix Timestamp.

I never used it but there is this library by @pipermerriam called ethereum-datetime, so you could call his contract to get what you want

  • 2
    Note that the ethereum-datetime does not provide the smart contract with the current datetime. ethereum-date provides you with the ability to format the time instead of displaying the number of seconds since 01/01/1970. – The Officious BokkyPooBah Apr 15 '16 at 15:56
  • @BokkyPooBah I assume this means there is no way of getting current time in solidity (yet) ? – Teleporting Goat Oct 28 '16 at 12:18
  • 1
    @TeleportingGoat In your solidity contract code you are able to access the block.timestamp - see ethereum.stackexchange.com/questions/413/… – The Officious BokkyPooBah Oct 28 '16 at 12:36

I believe what you're looking for is now:

chainStartTime = now;

now is an alias for block.timestamp, so the above is equivalent to:

chainStartTime = block.timestamp;

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.