How to display time values in the Anqi CMS template in the specified format?
date
The filter can display time values in the specified format. But it should be noted thatdate
The input must be atime.Time
value, 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 anddate
The usage method and result are the same. It isdate
alias for .
How to use
date
How to use filters:
{{ obj|date:"Time Format" }}
For examplecreateTime
Formatted 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