duceduc
November 27, 2020, 7:09am
1
Hello people. I thought I got it but not quite. I need to output the (date + 14) from now in this format 12/11
(month/day). So if today’s date is 11/27. I want to get 12/11. I have this code so far, but it will not work fully.
{% set today = now().month ~ '/' ~ (now().day+14) %}
{{ today }}
Result:
11/41
tom_l
November 27, 2020, 7:36am
2
I would have though this would work:
{{ (now() + timedelta(days = 14))|timestamp_custom('%-m/%d', true ) }}
It gets the correct date but does not format it for some reason.
Even this is not formatting:
{{ now()|timestamp_custom('%-m/%d', true ) }}
Tseven
November 27, 2020, 10:07am
3
You need to convert it to a timestamp first to be able to change the format.
Building on tom_I suggestion.
{{ as_timestamp(now() + timedelta(days = 14))|timestamp_custom('%-m/%d', true ) }}
Completing your initial post.
{% set today = as_timestamp(now() + timedelta(days = 14))|timestamp_custom('%-m/%d', true ) %}
{{ today }}
Result:
12/11
1 Like
duceduc
November 27, 2020, 10:59am
5
Thanks guys for taking the time to help out. Much appreciated.