Goal, trying to display a custom contact property that is a date in a pretty format. We created the property as a date picker and named it "plan_effective_date". Ill walk you through my thought process on this and please let me know what I am missing.
I found that the field is a string type using the "pprint" filter. So I started down the rabbit hole of finding some helper function that can format the date. I found "datetimeformat" but that can only accept a date object.
So I tried converting this string into a date object using "strtotime" filter. When I put "May 1, 2022" for example, in "plan_effective_date" it prints out as "5/1/22"
{% set effective_date = contact.plan_effective_date %} {# pprint = "(String: 5/1/22)" #}
{{ effective_date|strtotime("M/d/y") }}
{# Gives error:
com.hubspot.jinjava.interpret.InterpretException: stringToTime() could not match datetime input 5/1/22 with datetime format M/d/yy
#}
So far I have tried a few date match formating patterns and none of them have worked so far. I see the error: "com.hubspot.jinjava.interpret.InterpretException: stringToTime() could not match datetime input 5/1/22 with datetime format M/d/yy"
So how can I get past this first hudle of turning a string date into a date object? Any help is much appreciated!
It looks lik the only directive that you changed was from the "%B" to "%b" and both have the same result. Nothing is printed. I was expecting to see the date after the "test: " from my screenshot. But nothing is displaying. I do see the string of "5/1/22" when I just put out "{{ contact.plan_effective_date }}" So that tells me that there is data there.