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. – Aaron Voelker May 22 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. – Aaron Voelker May 22 at 18:51
up vote 4 down vote accepted

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

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

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

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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