How to display time value in specified format in Anqi CMS template?
dateThe filter can display time values in a specified format. But note that,datethe input must be atime.TimeThe value, otherwise it cannot be processed and an error will occur. The output format is set according to the Golang time format.
You can also usetime, and it isdatewith the same usage method and result. It isdateThe alias.
Usage method
dateHow to use the filter:
{{ obj|date:"时间格式" }}
For example, to convertcreateTimeFormatted as2006-01-02It can be written like this:
# createTime 需为 time.Time 值
{{ createTime|date:"2006-01-02" }}
# 显示结果
2023-02-09
Example Demonstration
{{ createTime|date:"2006-01-02" }}
# 显示结果
2023-02-09