Date filter function - Fluid Topics - Latest

Jinja Connector Reference Guide

Category
Reference Guides
Audience
public
Version
Latest

The Jinja connector has a date filter function called format_date. format_date makes date manipulation easier.

format_date(input_format, output_format)

format_date takes two arguments as input:

  • input_format
  • output_format

input_format and output_format take Python date format codes as values.

For example:

{{ data.my_date }}
1980-10-22T13:24:45:45454
{{ data.my_date[:10]|format_date('%Y-%m-%d', '%d/%m/%Y') }}
22/10/1980

In the previous example:

  1. The function first reduces the value of my_date to its first 10 characters using [:10].

    my_date is now 1980-10-22.

  2. The function then transforms 1980-10-22 (format of YYYY-MM-DD or %Y-%m-%d) to 22/10/1980 (format of DD-MM-YYYY or %d/%m/%Y).