How can I automatically display today's date in a pdf or email. I tried the "thank you date" token but the date format is 12-31-15 12:30. I need December 31, 2015... I tried plugging in this {$smarty.now|date_format} Still didn't work. Any ideas?


4 Answers 4


I think this would be a custom token to get it in the format that you're looking for, but it wouldn't be too difficult and I am pretty sure you'll be able to find one someone has already written -

Check out the bottom two links of this page:


The last post April 29: "We discovered at the sprint that just about everyone has written a token for this at some point"...

I think there was a good example on coleman's blog here, too, but the main content doesn't seem to be loading for me anymore:

https://civicrm.org/blog/colemanw/create-your-own-tokens-for-fun-and-profit (corrected link)


In order to get smarty to work in email templates you need to enable it editing the settings file civicrm.settings.php, as per CiviCRM documentation:

if (!defined('CIVICRM_MAIL_SMARTY')) {
     define( 'CIVICRM_MAIL_SMARTY', 1 ); // default is: define( 'CIVICRM_MAIL_SMARTY', 0 );

With smarty enabled, the following snippet should output the desired date format:

{$smarty.now|date_format} // Output: Jan 12, 2016
{$smarty.now|date_format:"%B %e, %Y"} // Output: January 12, 2016

As Eli says and references Coleman post is a very good example, simply pasting his code into an existing extension, or creating one for your needs, will work.


You could create a custom token and add the format you want. An example of such a token in a custom format (a long with lots of other tokens) you could find in the extension no.maf.tokens This extension contains specific tokens for a client and one of the tokens in the date of today in Norwegian.

See https://github.com/CiviCooP/org.civicoop.no.maf.ext/blob/master/org.civicoop.no.maf.tokens/maf_tokens.php#L72


This is posted as a comment in the top answer, but it deserves more visibility as an answer: You can install Fuzion's Civitoken extension.

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.