Countdown on Landing Page (Marketing Starter)

I know this is years later, but just for the sake of anyone searching for the fix on a similar issue, you can actually use hubl and unixtimestamps to solve this. For example:

{# The values here are not specific, so you can use non-abbreviated,translated or whatever #}{% set allDaysOfWeek = ["Sun", "Mon","Tues","Wed","Thur","Fri","Sat"] %}

Next, we basically we convert the date to a unix timestamp (# of milliseconds since January 1st 1970 when the standard was established), and convert it into days which we then mod by 7 (days in the week). “%” aka “mod”, gives the remainder after diving by the number it’s given (i.e. 10%3 == 1). The resulting value is the number of weekdays past that initial day: Jan 1st 1970, which was a Thursday (thus the + 4 before modding, Thursday being 4 days after Sunday, the first element in the daysOfWeek array).

{% set dayOfWeek = allDaysOfWeek[((((module.date|unixtimestamp)|int|float|divide(1000)|divide(60)|divide(60)|divide(24) )|round|int + 4)%7)] %}

The result:

<p>{{ module.date|format_date('long') }} is a {{ dayOfWeek }}</p>

Renders: February 1, 2024 is a Thursday

But that’s based on the assumption that you’re usung hubspots date-picker.
What if you don’t have your date in that format or instead want to find the time between two dates?
Then first you’ll need to convert both dates to unix timestamps before you subtract the earlier from the later date. For instance, how about a ‘Days til election voting’ counter? (static of course, you’ll need a bit of javascript if you want an animated one. Not much though)

{# Converting date with hubl filters so it can be 'math-i-fied'. For instance, days til election day: #}{% set currentDate = local_dt|unixtimestamp %}{# Future Date - example of formating date to unix timestamp #}{% set electionDay = ("2024-11-05T00:00:00+0530")|strtotime("yyyy-MM-dd'T'HH:mm:ssZ")|unixtimestamp %}{# The "2024-11-05T00:00:00+0530" here is being converted using the |strtotime filter by passing it the format that your input date is usingIn this case ("yyyy-MM-dd'T'HH:mm:ssZ") #}{% set timeDiff = ((electionDay - currentDate)|int|float|divide(1000)|divide(60)|divide(60)|divide(24))|round|int %}

*You can find a list of all the time patterns here or use an converter if your unsure what to pass the filter: SimpleDateFormat (Java Platform SE 7 )
The result:

<p>{{ timeDiff }} Days til Voting!</p>

Renders: 198 Days til Voting!
Adding hours/minute/seconds is as easy as simply stripping off the conversions from right to left --> |divide(24) [hours in a day]--> |divide(60) [minutes in an hour] --> |divide(60) [seconds in a minute] --> |divide(1000) [milliseconds in a second]. Do note (as previously mentioned) that these will be static numbers only updated when refreshing the page.