How to Format value from Date Picker with Hubl Filter?

I am trying to use the “datetimeformat” filter on a contact field of the Date picker field type. The issue I’m having is the filter is not recognizing the value of the property as a datetime data type, which I’m assuming it requires in order to work properly.

Here is an example of how I’m using it trying to display the month:

{{ contact.appointment_date | datetimeformat('%B') }}

The value of {{ contact.appointment_date }} without any filtering displays as mm/dd/yyyy format.
I feel as though I can’t be the only one experiencing this issue but I cant find any documentation on it either.

Any help is appreciated.

Thank you,
Josh

I am also curious about this. I was debugging the datetime objects that Hubspot sets on blog posts and the raw output looks like this:

`{% raw %}(PyishDate: 2017-03-28 12:40:45){% endraw %}````

It’s been a few years, but I’m curious if either @tjoyce or @joshm1 have an update here. I have run into a similar issue.

This HubL code:

Renders this:

Screen Shot 2021-05-19 at 2.19.18 PM.png

When I use

{{ contact.date_of_birth_hs|datetimeformat('%m/%d/%Y') }}

I’m expecting to get 01/01/1945, but instead I get a blank.

Same here. Documentation on this is horrible. It tells you to first apply “strtotime” for properties that aren’t set as a datetime timestamp. Hubspot date picker properties, I believe, aren’t datetime but date only. But the strtotime documentation is horrible as well. All it says is “Converts a datetime string and a datetime format into a datetime object.” but that doesn’t help me jack squat.

I’ve got a date property referenced and just want to apply formatting to only show the year:

In Hubspot, it shows as: 1 jan. 1990

What I want to show in my template: “1990”

What I did:

{{ contact.mydatefield|datetimeformat(“%Y”) }} → Gives blank

Frustrating.

I had the same issue. I used ‘date’ instead of ‘datetime’. The filter wasn’t working in Design Manager. Tried to convert ‘strtotime’ and back to datetimeformat. However …

{{ contact.appointment_date|datetimeformat(‘%B’)}} does work, not in template preview but in a draft or a published page. When you set the time in CMS page edit mode, the datetime is set correctly from the date picker and the filter works.

this post is old but if anyone is searching for this, as I was… this is what I did to show only year, using the format data action in a workflow: