How to work with dates in Sway

I want to store a paymentDate and renew the payment date with a given number of days.

ex: I have a struct called an agreement. assume it stores in a StorageMap. I want to modify the nextPaymentDate by adding 90 more days to the currently available date.

struct agreement{
id: u64,
nextPaymentDate: u64
}

How to achieve this? Be kind enough to change the data types if it is not suited to this work.

1 Like

To get the timestamp of a current block you may call the timestamp() function, defined here in the std-lib.

This will return a TAI64 timestamp from which you can then calculate the seconds needed for 90 days.

We have an issue to create more readable timestamps here. If this is an urgent issue I can try and pick it up as soon as possible!

1 Like

Thank you very much. I will try the approach.

if this is an urgent issue I can try and pick it up as soon as possible!

I am just doing some projects so nothing urgent. Take your time. Thanks again for reaching out

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.