Skip to main content

Hello, 

How would I add a dynamic expiration date to an e-mail so the client would know how long the coupon is valid?  I use dynamic coupon codes with 7 day expiration. 

Thank you so much, 

Gyte 

Hi @GyteStaine,

Thanks for your question! One way is to use django template tags to insert a dynamic expiration date, based on when the email was sent. For us, it looks like this:

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

And renders like this:

Valid through May 3, 2024

The resulting day is 14 days after today; you can change it to 7 for your needs. Django also gives more ways to format the date, you might want to play around with the format to see what you want.

Hope this helps!


Hello Jess, 

amazing! Thank you so much! I have already implemented and it works :) 

 


@GyteStaine,

Great! I’m so glad it helped! :-)

Also, I should have linked to the Klaviyo documentation, which is here. It has the same code, and some other information as well.

Best of luck with your marketing efforts!


Reply