I deployed a smartpy contract in florencenet via smartpy.io. The command sp.timestamp_from_utc_now() used inside the program seems to be not giving the current time. Instead it is giving the same time the contract is deployed. How do I get the current time/timestamp in smartpy?
1 Answer
sp.timestamp_from_utc_now()
is a helper function that only works at compilation time, meaning that it produces a constant and doesn't update at runtime.
timestamp_from_utc_now()
should be moved to sp.utils
soon, which should avoid confusion.
You want to use the instruction sp.now which gives the current block timestamp.
-
1thanks a lot, @Rodrigo Quelhas. Your suggestion worked as per my requirement.– MrHumbleJul 23, 2021 at 14:19