CMS Development

nathanjosiah
Membre

Filtering HubDB rows based on today's date not adjusting for timezone

I have a HubDB table with a Datetime column.

 

In my file I have the following:

 

 

{% set params = "&orderBy=event_date" %}
{% set events = hubdb_table_rows(123456, params) %}
{% for row in events %}
  {% if (row['event_date']|unixtimestamp) >= (local_dt|unixtimestamp) %}
    row here
  {% endif %}
{% endfor %}

This is supposed to filter out past events, and it does, except it's off by 8 hours (the UTC offset of our timezone) and so event rows are hiding sooner than they should.

 

My triage solution was to change condition line to this:

 

  {% if (row['event_date']|unixtimestamp) >= (local_dt|unixtimestamp - 28800000) %}

However, this is only a temporary fix as it won't adjust for daylight savings. 

 

 

Is there some way to make this behave?

 

(P.S. The result is the same if I move the filter into the parameters instead such as "&orderBy=event_date&event_date__gte=" ~ (local_dt|unixtimestamp))

 

0 Votes
1 Réponse
roisinkirby
Équipe de développement de HubSpot
Équipe de développement de HubSpot

Filtering HubDB rows based on today's date not adjusting for timezone

Hey @nathanjosiah check out this post, @giozua was able to help @SvenVanbrabant with a similar query: SOLVED: Filter HubDB data based on today's date

0 Votes