4

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.

2
  • 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. Commented May 22, 2018 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. Commented May 22, 2018 at 18:51

1 Answer 1

4

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

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

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

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.