To display the current time in the template of Anqi CMS, you can use the now tag. The now tag allows you to format and display the current time according to the Go time formatted string.
Use the now tag
In the template, you can call the now tag using the following method:
{% now "2006-01-02 15:04:05" %}
This will display the current time, in the format年-月-日 时:分:秒
.
Time formatted strings for Go language
The Go language uses specific reference times to define the time format. The following are commonly used time format strings:
2006
Year01
moon02
day15
Time (24-hour system)04
point05
Second
You can combine these strings to create a custom time format. For example
2006-01-02
Will be displayed as2023-04-01
15:04:05
Will be displayed as16:45:30
2006年01月02日 15时04分05秒
Will be displayed as2023年04月01日 16时45分30秒
Detailed documentation of now tags
The now tag is part of the Anqi CMS template engine, which allows you to insert the current time into the template. You need to provide a format string that follows the Go language's time formatting rules.
grammar
{% now [format] %}
parameter
format
:A string that specifies the display format of time. This is optional; if not provided, will use the default time format.
Example:
{% now "2006年01月02日" %}
This will display the current date as April 1, 2023.