To display the current time in the Anqi CMS template, you can use the now tag.The `now` tag allows you to format and display the current time using the Go language's time format string.
Use the now tag
In the template, you can use the following method to call the now tag:
{% now "2006-01-02 15:04:05" %}
This will display the current time, formatted as:年-月-日 时:分:秒
.
Go language time formatting string
Go language uses a specific reference time to define time formats.The following are commonly used time formatting strings:
2006
Year01
Month02
Day15
Hour (24-hour format)04
Minute05
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 the now tag
The `now` tag is part of the Anqi CMS template engine, it allows you to insert the current time in the template.You need to provide a format string that follows the Go language's time formatting rules.
Syntax:
{% now [format] %}
Parameter:
format
A string that specifies the format of the date display. This is optional; if not provided, the default date format will be used.
Example:
{% now "2006年01月02日" %}
This will display the current date as of 2023-04-01.