I expected to be able to print out the time in a contract but...


didn't get compiled and I get the error "use of undeclared identifier 'current_time'"

2 Answers 2


Time is treated in a special way inside the blockchain. The main reason for the limitation is that the blockchain data needs to be consistent and reproducible so playback of the blockchain reaches the same state.

This should work:

  • Ami, when I compile im getting an error error: use of undeclared identifier 'now'; did you mean 'new'? print(now());
    – Bill
    Jul 8, 2019 at 2:57
  • What version are you using for the eosio.cdt?
    – Ami Heines
    Jul 8, 2019 at 4:13
  • if i run cleos version client i get Build version: 448287d5
    – Bill
    Jul 8, 2019 at 4:25
  • What version of the eosio.cdt? Try this: >> eosio-cpp --version
    – Ami Heines
    Jul 8, 2019 at 4:59
  • eosio-cpp --version eosio-cpp version 1.6.1 but i did just run brew upgrade eosio
    – Bill
    Jul 8, 2019 at 5:10

In more recent version of eosio.cdt, now(), which used to return the seconds since the beginning of the unix epoch, has been removed.

The new way of doing this would be:

#include <eosio/system.hpp>


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.