How to format dates in email templates

When using a date field in the email templates it is important to use it with formatting function for the value to be represented in the format set in the language settings.

The function for formatting a date is format_date​ and by default is using the format specified in the language settings. However, it is possible to specify a custom one (using LDML format), if needed.

An example of adding a date in an email template is shown in the example below:

<p>Date Created: <t t-out="format_date(object.date_order) or ''"></t></p>

In case it is needed to display datetime​ or time​ values the functions available for them are: format_datetime​ and format_time​.


in Tips