How does one retrieve current time in milliseconds? now() returns time in seconds.

I know that you can use fc::time_point::now() from fc/time.hpp, but that include does not seem to work in contracts.

  • I would like to see an example too, but it seems it should be possible via eos/contracts/eosiolib/time.hpp which has a time_point() operator in its block_timestamp class. This computes the time by multiplying 500ms by the slot id, which increments each block. May 22 '18 at 17:17
  • Just realized you said milliseconds. I don't know if this would be possible in the smart contact, because determinism? Seconds work because blocks are clocked to 0.5s intervals. May 22 '18 at 18:51

From Dan Larimer himself when you asked in the EOS Developer telegram

current_time() returns time in microseconds (rounded to block time)

  • 1
    Yes, so essentially you can only get time at a resolution of 0.5s
    – Syed Jafri
    May 23 '18 at 6:54

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.