Display time values ​​in the specified format

How to display time values ​​in the Anqi CMS template in the specified format?

dateThe filter can display time values ​​in the specified format. But it should be noted thatdateThe input must be atime.Timevalue, otherwise it cannot be processed and an error is reported. The output format is set according to Golang's 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:"Time Format" }}

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

# createTime must be time.Time value
{{ createTime|date:"2006-01-02" }}
# Display result
2023-02-09

Sample Demo

{{ createTime|date:"2006-01-02" }}
# Display result
2023-02-09