Display time values in specified format

How to display time value in a specified format in Anqi CMS template?

dateThe filter can display time values in a specified format. But be careful that,datethe input must be atime.Time[en]Value, otherwise the processing cannot be performed and an error will be reported. The output format is set according to the Golang time format.

[en]You can also usetime[en], it anddate[en]are used in the same way and have the same result. It isdatealias.

Usage Instructions

dateHow to use the filter:

{{ obj|date:"时间格式" }}

For example, to transformcreateTimeformatted as2006-01-02then it can be written like this:

# createTime 需为 time.Time 值
{{ createTime|date:"2006-01-02" }}
# 显示结果
2023-02-09

Here is an example demonstration

{{ createTime|date:"2006-01-02" }}
# 显示结果
2023-02-09