Is there a built-in way to get timestamps in Sway?
I also have this problem
The standard library has you covered when it comes to timestamps!
the std::block module has height(), timestamp() and timestamp_of_block(block_height: u64) functions you can use.
Reference:
The timestamp returned from the std-lib is a TAI64 format timestamp, which is different than unix. Adding 86400 to the timestamp will add 1 day.
Abstractions over common time periods should be provided by the std-lib imo
This is a good idea, @mohammadfawaz thoughts on this being introduced to either sway-libs or std-lib?
I.e. time unites: 1 day, 1 hour, 1 second etc.
Good idea indeed. Created an issue here: Consider generating more readable timestamps in the standard library · Issue #3945 · FuelLabs/sway · GitHub