如何使用模板在烧瓶中格式化日期

use*_*822 0 python templates flask

我有日期时间格式的日期列表,我很喜欢这样做。

表格范例:

{% for date in dates %}
    {{date}}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

cod*_*eek 5

您可以使用python strftime函数。它可以在Jinja2中使用。

{% for date in dates %}

    {{ date.strftime('%Y-%m-%d') }}

{% endfor %}
Run Code Online (Sandbox Code Playgroud)