str_to_date
Converts a string timestamp into a date value to be passed. This value can be passed to another filter that takes a date value such as date.
Input
{{ article.published_at | str_to_date }}
Output
2024-01-25 16:51:29 +0000
Input
{{ '2024-01-25 16:51' | str_to_date }}
Output
2024-01-25 16:51:29 +0000
str_to_date
handles unix timestamps
Input
{{ '980989200' | str_to_date }}
Output
2001-02-01 01:00:00 +0000
str_to_date
can be combined with the date filter to format the date value.
Input
{{ '2024-01-25 16:51' | str_to_date | date: '%Y-%m-%d' }}
Output
2024-01-25
Last updated