date_str
Converts a string timestamp into another date format returned as a string. The format for this syntax is the same as strftime. date_str is nearly the same as piping a string to str_to_date then piping the value to date.
Input
{{ article.published_at | date_str: "%a, %b %d, %y" }}Output
Fri, Jul 17, 15Input
{{ article.published_at | date_str: "%Y" }}Output
2015date_str works on unix timestamps.
Input
{{'980989200' | date_str: '%Y-%m-%d %H:%M' }}Output
2001-02-01 01:00Input
{{'1706201489' | date_str: '%Y-%m-%d %H:%M' }}Output
2024-01-25 16:51To get the current time, pass the special word "now" (or "today") to date.
Input
Output
Note that the value will be the current time of when the page was last generated from the template, not when the page is presented to a user if caching or static site generation is involved.
Last updated