Display time values ​​in the specified format

How to display time values in a specified format in the AnQi CMS template?

dateThe filter can display time values ​​in the specified format. But it should be noted thatdateThe input must be atime.TimeOtherwise, it cannot be processed and an error will be reported. The output format is set according to the Golang time format.

You can also usetime, it anddateThe usage method and result are the same. It isdatealias for .

How to use

dateHow to use filters:

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

For examplecreateTimeFormatted as2006-01-02, you can write it like this:

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

Sample Demo

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