Skip to main content
Solved

How to create date variable to use in countdown until Christmas?

  • October 3, 2023
  • 1 reply
  • 115 views

Forum|alt.badge.img+1

Hi, I’m trying to add a “X days until Christmas” line to my email where X is the difference between today’s date and 25th Dec, as a count.

I’ve tried using Django’s timeuntil function:

{{ xmas|timeuntil:today }}

but unsure how to define “xmas”? {% with xmas=date(2023, 12, 25) %} is giving an error

Would appreciate any help with this! Hoping to avoid using a timer as I want it to look human

Best answer by Taylor Tarpley

Hi there @yayifications

 

Thanks for sharing your question with us! Happy to help! 

 

I would recommend utilizing a countdown timer for this use case! However, I do believe that your xmas date is configured incorrectly about as well. I believe the date would need to be as follows instead of the commas.

date:'Y-m-d'

 

Thanks for participating in the Community!

-Taylor 

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

1 reply

Taylor Tarpley
Community Manager
Forum|alt.badge.img+60
  • Community Manager
  • 2148 replies
  • Answer
  • October 4, 2023

Hi there @yayifications

 

Thanks for sharing your question with us! Happy to help! 

 

I would recommend utilizing a countdown timer for this use case! However, I do believe that your xmas date is configured incorrectly about as well. I believe the date would need to be as follows instead of the commas.

date:'Y-m-d'

 

Thanks for participating in the Community!

-Taylor