Timestamp or date in Rust or Motoko

System time

The canister can query the IC for the current time.

ic0.time : () -> i64

The time is given as nanoseconds since 1970-01-01. The IC guarantees that

  • the time, as observed by the canister, is monotonically increasing, even across canister upgrades.
  • within an invocation of one entry point, the time is constant.

The system times of different canisters are unrelated, and calls from one canister to another may appear to travel “backwards in time”.


NOTE

While an implementation will likely try to keep the System Time close to the real time, this is not formally part of this specification.

1 Like