Skip to content
On this page

Timestamps

SmartPy's type for timestamps is sp.timestamp. It corresponds to the timestamp type in Michelson.

There are two ways to specify a literal timestamp:

  • sp.timestamp(n) refers to the moment in time n seconds since the Epoch. For example, sp.timestamp(1571659294) represents 2019-10-21T12:01:34Z.

  • sp.timestamp_from_utc(year, month, day, hours, minutes, seconds) represents the given time in UTC. For example sp.timestamp_from_utc(2021, 12, 31, 23, 59, 59) corresponds to 2021-12-31T23:59:59Z.

sp.now  → 

The current block timestamp, a.k.a. the "minimal injection time". For a detailed explanation see Michelson's NOW instruction.

sp.add_seconds(t: sp.timestamp, secs: sp.int) → sp.timestamp

Adds secs seconds to t.

sp.add_days(t: sp.timestamp, days: sp.int) → sp.timestamp

Adds days days to t.