Cookbook
Time and date

Time and date

How to get the current time

Use the now() method to obtain the current standard Unix time (opens in a new tab).

If you need to store the time in state or encode it in a message, use the following serialization: Int as uint32.

let currentTime: Int = now();
 
if (currentTime > 1672080143) {
    // do something
}
🤔

Didn't find your favorite example of working with time and date? Have cool implementations in mind? Contributions are welcome! (opens in a new tab)