Customizing the date format for "Last Updated"

This article will show you how you can customize the date format used to display the Last Updated date of an article. This can be done from the site text translation area.

Navigate to the Settings Text > Sidebar translation section and edit the Last Updated field. By default it will have the following value:

<h3>Last Updated</h3><p>{{ lesson.posted_at | format_date }}</p>

You can customize the format of the date by passing some parameters to format_date. When no parameters are passed to format_date then the date is displayed as Month Day, Year using the formatting string %b %d, %Y.  If you want to display the Day Month, Year you could use %d %b, %Y as the formatting string.

Here is what the Last Updated field would look like when passing in a custom formatting string:

<h3>Last Updated</h3><p>{{ lesson.posted_at | format_date(date, "%d %b, %Y") }}</p>

There is a visual tool for creating formatting strings available at http://strftime.net. Use the tool to create a formatting string that displays the date in the format you would like and then use the example above to create your own Last Updated field value.

0 Comments

Add your comment

E-Mail me when someone replies to this comment