Skip to Content

Timezones on HubSpot's "Date" and "Date and Time" module fields

When creating a custom module, HubSpot offer two datetime fields: 

  • Date - a simple datepicker where the content editor can select the date
  • Date and Time - a field in which the content editor can select both the date and time (at intervals specified in the module)

What timezone is used in the field?

When you populate a default value or if a content editor populates the field, the timezone used is the account's timezone, which you'll find under Settings > Account Defaults by clicking into the General tab > "Time zone":

timezone-settings

Regardless of where the content editor is located, this is the timezone that will be used, which can make it tricky if you have content editors across different timezones. 

What timezone is displayed on the page?

When a user visits a page that contains a module with a Date or Date and Time field, the timezone displayed will also be the account timezone, unless you use a filter to update the timezone. 

Using filters to format the date/time and their effect on timezones

However, you can use the format_date or format_datetime filters to modify the format of your date and time. 

An important thing to note is that, even though the documentation says that the timezone parameter for these filters is optional, if you don't include it, it will default to Coordinated Universal Time (UTC). 

(This was not the case with the deprecated filter datetimeformat).

Therefore, you'll likely want to set the timezone in your format_date or format_datetime filters.

My suggestion is to use the local_time_zone variable ("the time zone, as configured in your HubSpot Report Settings."), which is also your account timezone and the timezone that the content editor will set with the field (regardless of the timezone they're located in). 

You can also add a custom "timezone" field (e.g. a choice field with a dropdown containing the list of timezones in IANA TZDB format), but it can be confusing for the content editor as the field itself will still use the account's timezone and not the "timezone" field's timezone. It's only modifying the output on the page, not the field within the module.

What this looks like in practice

Confused by that last bit? So was I. Below are some tests I ran so that you can see how the timezone field works in practice. 

For my example I tested what the content editing looks like for a user in a different timezone from the account's: 

  • I set my account's timezone to UTC -07:00 Vancouver
  • I myself am currently located in UTC -04:00 Toronto

I created a simple module with a Date and Time field and the following HTML/HubL:

Then I created a page using the module and set the time to 2023-06-20 05 at 05:00 PM (note that my timezone is America/Toronto, but this time will be set in the account's timezone of America/Vancouver).

This was the output when publishing the page:

  • Account's Timezone (local_time_zone): America/Vancouver
  • Date and time Field (value only): 2023-06-20 17:00:00
  • Date and time Field (format_datetime, no timezone): Wednesday, June 21, 2023 | 00:00 AM Z
  • Date and time Field (format_datetime, local timezone): Tuesday, June 20, 2023 | 17:00 PM PT
  • Date and time Field (format_datetime, Toronto timezone): Tuesday, June 20, 2023 | 20:00 PM ET
  • Date and time Field (format_datetime, Vancouver timezone): Tuesday, June 20, 2023 | 17:00 PM PT

In summary: 

  • The module field value that the content editor enters uses the account's timezone (America/Vancouver), regardless of their timezone (America/Toronto).
  •  If you just print out the value of the field, it will use the account's timezone (America/Vancouver).
  • If you use the format_date or format_datetime filter on the value of the field with no timezone parameter set, it will set it to Coordinated Universal Time (UTC).
  • If you use the format_date or format_datetime filter with the local_time_zone variable in the filter's timezone parameter, it will set it to the account's timezone (America/Vancouver)
  • Alternatively, you can also set any other timezone using the format_date or format_datetime filter (hard coded or using another custom field).

←  Previous Article

How to design a website for the HubSpot CMS

Next Article  →

Compare two dates using HubL

Contact

Get help from a HubSpot CMS Expert

  • Custom HubSpot themes and reusable and easy-to-use HubSpot templates and modules
  • Technical support and guidance on the HubSpot CMS