date
Converts a date string into a specified format.
You can use built-in format types or use placeholders to customize the output format.
date_string | date(format=format) returns a string.
Required params
date_string string: A date string. Format: ISO 8601. Example: 2024-08-31T02:20:26+08:00.
Optional params
format string: The target output format. You can use a built-in format type or a custom format. For more information on how to use placeholders to customize the output format, refer to strftime reference and sandbox. If you want to use a built-in format type, valid values are:
-
default(default): A format including the weekday, date, specific time, and timezone offset. Example:Monday, December 31, 2018 at 1:00 pm -0500. -
abbreviated_date: An abbreviated date. Example:Dec 31, 2018. -
basic: A basic numeric date format. Example:12/31/2018. -
date: A full date. Example:December 31, 2018. -
date_at_time: A date with the specific time. Example:December 31, 2018 at 1:00 pm. -
on_date: A date preceded by a preposition. Example:on Dec 31, 2018.
Example
The following example is used to convert date strings into three different formats.
{{ "2022-04-14T16:56:02-04:00" | date() }}
{{ "2022-04-14T16:56:02-04:00" | date(format="basic") }}
{{ "2022-04-14T16:56:02-04:00" | date(format="%B %d, %Y") }}