4

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

8

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
  • 1
    Where was this change mentioned, I don't see it in any release notes. – Jason Bert Apr 3 '19 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. – Phillip Hamnett - EOS42 Apr 3 '19 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 Jun 18 '19 at 23:39
  • 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 Jun 18 '19 at 23:45
  • and what the hell was wrong with providing now() anyway?? I'm so aggravated – ekkis Jun 18 '19 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, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.