5

Depending on which version of EOSIO you use, there are different options available for finding the current time. What are they?

2 Answers 2

9

Until eosio.cdt v1.6

You could use:

  • eosio::current_time()
  • now()

From eosio.cdt v1.6 onwards

You have to #include <eosio/system.hpp> and then you can use:

  • eosio::current_time_point
  • eosio::current_block_time
6
  • 1
    Where was this change mentioned, I don't see it in any release notes.
    – Jason Bert
    Commented Apr 3, 2019 at 11:55
  • 2
    I don't think they mentioned it directly. It was just something you had to find out for yourself. That is why I made a question and answered it, anticipating people having this problem. Commented Apr 3, 2019 at 21:13
  • 1
    thank you. I wish they would bloody document stuff like this so poor sods like me don't spend all kinds of hours trying to figure out why something doesn't work. question: I see in the 1.6.1 version of the CDT, that now() is still defined: github.com/EOSIO/eosio.cdt/blob/master/libraries/eosiolib/… however, if I #include <eosio/system.hpp> I still get the error "use of undeclared identifier 'now'; did you mean 'new'?" -- why is that and how do I fix it?
    – ekkis
    Commented Jun 18, 2019 at 23:39
  • 1
    and if I look in libraries/eosiolib/system.hpp, I don't see either current_time_point or current_block_time (I need to know the return types)... how does this work? I see that including from eosiolib is deprecated and we must include from eosio, but I don't see any such directory!
    – ekkis
    Commented Jun 18, 2019 at 23:45
  • 1
    and what the hell was wrong with providing now() anyway?? I'm so aggravated
    – ekkis
    Commented Jun 18, 2019 at 23:45
0

In older version we can only get the current block time with publish_time(). But now its available also in eosio::current_time_point eosio::current_block_time. Hope this helps you.

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.