APIs & Integrations

Ael31
Member

Issue Displaying Time in Custom DateTime Field within Email Templates

Hi 😀

 

My team and I have recently created a custom contact property of the DateTime type (named "datetime2") using the HubSpot API via Postman:

Ael31_0-1712857042769.png

We can confirm that this field has been successfully created and that the values are properly displayed within the HubSpot user interface, including both date and time.

Ael31_1-1712857153827.pngAel31_2-1712857162591.png

However, we are encountering an issue when incorporating this field as a personalization token in our email templates. Although the "datetime2" field contains both date and time information, only the date is displayed in the email templates, with the time being omitted.

Ael31_3-1712857182939.png

Ael31_4-1712857193390.png

In an attempt to address this issue, we have tried formatting the field through HTML in the email template, using the following syntax:

 

{{ contact.datetime2 | format_datetime("dd/MM/yyyy HH:mm:ss", 'America/Mexico_City') }}

{{ contact.datetime2|datetimeformat('%d/%m/%Y %H:%M') }}

Ael31_5-1712857213766.png

 

Unfortunately, upon applying this formatting, the field stops being displayed altogether in the email template.

 

We would greatly appreciate your help on this matter and provide us with guidance on how to resolve it 🙏 to ensure that both the date and time are correctly displayed in our email communications.

 

Our aim is to make our emails feel more personal, and getting the date and time right is super important for achieving that!

 

2 Replies 2
WMM_Inbound
Contributor | Partner
Contributor | Partner

Issue Displaying Time in Custom DateTime Field within Email Templates

Hi @Ael31,

I recently had the problem of formatting a date in a Quote and i needed to add   "|int" to display the date correctly, maybe that is missing in your case as well.
My code looks like this:

{% set TIMEZONE = QUOTE.hs_timezone || 'Europe/Berlin' %}
{% set LOCALE = QUOTE.hs_locale || 'de-DE' %}

{{ QUOTE.hs_expiration_date|int|datetimeformat('%e.%m.%Y', TIMEZONE, LOCALE) }}<br />






Jaycee_Lewis
Community Manager
Community Manager

Issue Displaying Time in Custom DateTime Field within Email Templates

Hi, @Ael31 👋 Thanks for your question. Let's invite some of our community members to the conversation — @MBERARD @WMM_Inbound @zach_threadint, do you have any experience or tips you can share with @Ael31? Thank you very much for taking a look! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes