Skip to main content
Solved

Interest current date + 7 Days into email template

  • February 17, 2021
  • 4 replies
  • 700 views

Forum|alt.badge.img+2

Hi There,

 

I need to put an expiration date in a flow template, it show the current date (of email sent to customer) and the expiration date will be 7 days from current date.

 

Ideally it would be the D d M Y format but if this isn’t possible anything else would do.

 

I’ve check Django resources, however have had no luck at getting the date to show correctly.

 

Any help would be greatly appreciated. Thanks, Reece

Best answer by retention

@Reece Stevenson 

It is possible, but unfortunately not in the D-M-Y format for the +7 days.

 

Today: {% today '%Y-%m-%d' as today %} {{ today }}

7 Days Later: {% today '%Y-%m-%d' as today %} {{ today|days_later:7 }}

 

Note the date needs to be in the format '%Y-%m-%d' OR '%Y-%m-%dT%H:%M:%S' OR '%m-%d-%Y' for the +7 days to work.

 

Hope this helps!

View original
Did this topic or the replies in the thread help you find an answer to your question?

4 replies

retention
Partner - Platinum
Forum|alt.badge.img+62
  • 2025 Champion
  • 920 replies
  • Answer
  • February 17, 2021

@Reece Stevenson 

It is possible, but unfortunately not in the D-M-Y format for the +7 days.

 

Today: {% today '%Y-%m-%d' as today %} {{ today }}

7 Days Later: {% today '%Y-%m-%d' as today %} {{ today|days_later:7 }}

 

Note the date needs to be in the format '%Y-%m-%d' OR '%Y-%m-%dT%H:%M:%S' OR '%m-%d-%Y' for the +7 days to work.

 

Hope this helps!


Forum|alt.badge.img+2

Great thanks for the help, Joseph!


Jakub
Partner - Silver
Forum|alt.badge.img+13
  • Partner - Silver
  • 125 replies
  • November 10, 2023

Hi @retention,

This is still the only option to go with date with time using days_later?
%Y-%m-%dT%H:%M:%S - because wit that structure its not very nice to show in newsletter :)

 

 


JessFosnough
Expert Problem Solver IV
Forum|alt.badge.img+23
  • Expert Problem Solver IV
  • 194 replies
  • December 26, 2024

@Jakub ,

I don’t know if the formats above are still the only option, but I have been able to display a more friendly version of the date with this code:

{% today '%Y-%m-%d' as today %} {{ today|days_later:30|format_date_string|date:'F j, Y' }}

This gives me:

January 25, 2025

I updated the date format, based on Django documentation:

{% today '%Y-%m-%dT%H:%M:%S' as today %} {{ today|days_later:30|format_date_string|date:'F j, Y g:i A' }}

and received the output of:

January 25, 2025 1:17 PM

Hope this helps!