# How to work with dates in Sway

**URL:** <https://forum.fuel.network/t/how-to-work-with-dates-in-sway/4736>\
**Category:** Sway\
**Created:** [March 10, 2024, 5:49am UTC](https://forum.fuel.network/t/how-to-work-with-dates-in-sway/4736 "2024-03-10T05:49:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ran](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/ran/32/2417_2.png) [@Ran](https://forum.fuel.network/u/Ran)\
**Post date:** [March 10, 2024, 5:49am UTC](https://forum.fuel.network/t/how-to-work-with-dates-in-sway/4736/1 "2024-03-10T05:49:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bitzoic](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/bitzoic/32/2077_2.png) [@bitzoic](https://forum.fuel.network/u/bitzoic)\
**Post date:** [March 12, 2024, 3:45am UTC](https://forum.fuel.network/t/how-to-work-with-dates-in-sway/4736/2 "2024-03-12T03:45:08Z")

</div>

To get the timestamp of a current block you may call the `timestamp()` function, defined [here](https://github.com/FuelLabs/sway/blob/64d5398119cf81a1b66ed7691cd4505c5d371ca4/sway-lib-std/src/block.sw#L60) 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](https://github.com/FuelLabs/sway/issues/3945). If this is an urgent issue I can try and pick it up as soon as possible!

---

<div class="post-metadata">

**Author:** ![Ran](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/ran/32/2417_2.png) [@Ran](https://forum.fuel.network/u/Ran)\
**Post date:** [March 12, 2024, 3:59am UTC](https://forum.fuel.network/t/how-to-work-with-dates-in-sway/4736/3 "2024-03-12T03:59:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [April 2, 2024, 12:00am UTC](https://forum.fuel.network/t/how-to-work-with-dates-in-sway/4736/4 "2024-04-02T00:00:18Z")

</div>

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