Skip to main content
Contributor I
October 3, 2023
Solved

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

  • October 3, 2023
  • 1 reply
  • 195 views

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

    This topic has been closed for replies.
    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 

    1 reply

    Taylor Tarpley
    Community Manager
    Community Manager
    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