2

I'm trying to format a custom date field using smarty to send emails. What I want is to have the day of the week included, as "Wednesday, April 18, 2018". It seems that this should work:

{contact.custom_105|date_format:"%A, %B %e, %Y"}

But the mail send hangs. Also hangs if I just use

{contact.custom_105|date_format}

I can use {contact.custom_105} to send the preformatted date "03/01/2018 3:15AM", so I know I'm working with the correct field.

How can I get this formatted as I want?

2
  • I confirm it does not work, a data custom field is returned as a string and it is not recognised by smarty as a datestamp. This is probably a bug Commented Mar 1, 2022 at 17:40
  • Hmm. There must be something else going on. I tested the exact code in my answer above with a direct Email (not in a message template) and it returned "Thursday, March 3, 2022". Are you sure your custom field is a Date field? Commented Mar 2, 2022 at 18:02

1 Answer 1

5

Found the answer. The civi field token must be captured to a Smarty variable first:

{capture assign=arr}{contact.custom_105}{/capture}{$arr|date_format:"%A, %B %e, %Y"}
1
  • This doesn't seem to work for me and still hangs. I think the problem may be that the custom field comes in as a string rather than a datestamp and I think its still a string from the capture/assign.
    – Mick Kahn
    Commented Dec 8, 2019 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.