Nikolai Samteladze
Nikolai Samteladze

Reputation: 7797

Mandrill Templates With Handlebars - How To Format Date

Mandrill has a great feature that allows one to use Handlebars in templates to customize email content. See docs here.

One of the helpers that Madnrill supports is date that can be used like {{#date}}. The default date format is d/m/Y. My question is how can I specify a different date format (e.g. yyyy)?

I need to display something like 2015 Name. I tried:

Appreciate you help ;)

Upvotes: 6

Views: 3882

Answers (2)

Nikolai Samteladze
Nikolai Samteladze

Reputation: 7797

The issue was 2-fold:

  • You should use {{date}} instead of {{#date}}
  • You should use double quotes for formatting

The correct syntax would be {{date "Y"}}.

Mandrill also updated their docs that now provide more details on handlebars syntax.

Upvotes: 7

Matty77
Matty77

Reputation: 21

I would assume this may follow the original Merge Tag formatting. Have you tried this?

http://kb.mailchimp.com/merge-tags/all-the-merge-tags-cheatsheet

Use |DATE:FORMAT| to show the current date in a given format. For example, |DATE:d/m/y| where d is replaced by the day, m by the month, and y by the year. View a full reference of date options on the PHP website. This format isn't available for automation workflows.

Upvotes: 2

Related Questions