Add days, months, or years to the current date and format the output
A Yaak template function plugin that allows you to manipulate dates by adding days, months, or years to the current date and formatting the output.
Once installed, you can use the dateAdd template function in your Yaak requests:
${[ dateAdd() ]}
Returns the current date in YYYY-MM-DD format.
${[ dateAdd(7) ]}
Returns the date 7 days from now.
${[ dateAdd(0, 3) ]}
Returns the date 3 months from now.
${[ dateAdd(0, 0, 1) ]}
Returns the date 1 year from now.
${[ dateAdd(-7, -1, 0) ]}
Returns the date 7 days and 1 month ago.
${[ dateAdd(0, 0, 0, 'DD/MM/YYYY') ]}
Returns today’s date in DD/MM/YYYY format.
${[ dateAdd(15, 2, 1, 'MMMM D, YYYY') ]}
Returns the date 15 days, 2 months, and 1 year from now, formatted as “January 15, 2026”.
The plugin supports the following format tokens:
| Token | Description | Example |
|---|---|---|
YYYY |
4-digit year | 2025 |
YY |
2-digit year | 25 |
MMMM |
Full month name | January |
MMM |
Short month name | Jan |
MM |
2-digit month | 01 |
M |
Month number | 1 |
DD |
2-digit day | 05 |
D |
Day number | 5 |
dddd |
Full day name | Monday |
ddd |
Short day name | Mon |
dd |
Min day name | Mo |
d |
Day of week (0-6) | 1 |
HH |
24-hour (2-digit) | 13 |
H |
24-hour | 13 |
hh |
12-hour (2-digit) | 01 |
h |
12-hour | 1 |
mm |
2-digit minutes | 05 |
m |
Minutes | 5 |
ss |
2-digit seconds | 09 |
s |
Seconds | 9 |
SSS |
Milliseconds | 123 |
A |
AM/PM uppercase | PM |
a |
am/pm lowercase | pm |
Z |
Timezone offset | +01:00 |
ZZ |
Timezone offset (no colon) | +0100 |
X |
Unix timestamp (seconds) | 1735000000 |
x |
Unix timestamp (milliseconds) | 1735000000000 |
| Format | Example Output |
|---|---|
YYYY-MM-DD |
2025-01-15 |
DD/MM/YYYY |
15/01/2025 |
MM/DD/YYYY |
01/15/2025 |
MMMM D, YYYY |
January 15, 2025 |
dddd, MMMM D, YYYY |
Wednesday, January 15, 2025 |
YYYY-MM-DD HH:mm:ss |
2025-01-15 14:30:45 |
DD MMM YYYY HH:mm |
15 Jan 2025 14:30 |
YYYY-MM-DDTHH:mm:ssZ |
2025-01-15T14:30:45+01:00 |
X |
1735000000 (Unix timestamp) |
{
"Authorization": "Bearer token",
"Expires": "${[ dateAdd(7, 0, 0, 'YYYY-MM-DDTHH:mm:ssZ') ]}"
}
GET /api/reports?start_date=${[ dateAdd(-30) ]}&end_date=${[ dateAdd(0) ]}
{
"appointment_date": "${[ dateAdd(14, 0, 0, 'YYYY-MM-DD') ]}",
"follow_up_date": "${[ dateAdd(44, 0, 0, 'YYYY-MM-DD') ]}"
}
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
For issues or questions: