How can the scheduled publishing function of AnQi CMS accurately display the publish time on the front end through `stampToDate`?

Calendar 👁️ 65

As an experienced website operations expert, I deeply understand the art of content release timing and its profound impact on user experience, search engine optimization, and even operational efficiency.AnQiCMS (AnQi CMS) was born to meet these needs, and its 'Time Factor-Scheduled Publishing Function' is a powerful tool in the hands of content operators.But having strong publishing capabilities is not enough, how to present these carefully set publishing times elegantly and accurately to the readers is equally important. This is exactlystampToDateThis is the place where the template tag really shines.

Scheduling publishing feature: the cornerstone of flexible operation

AnQiCMS's 'Time Factor - Scheduled Publishing Feature' is undoubtedly one of its core highlights, giving content operations great flexibility.Imagine that you can be inspired to create content at night, but set the publication time for the next morning when users are active at peak hours, or schedule content release plans in advance for holidays without the need for manual monitoring.

In the AnQiCMS backend, when you edit a document, you will find a field named "Publish Time".By default, it will automatically fill in the current date and time.However, if you wish for this document to go live at a specific future date and time, simply set this field to the future date and time.AnQiCMS will intelligently publish content after reaching the moment, greatly enhancing the flexibility and automation level of content operations.The document clearly states, the format of this publication time is2006-01-02 15:04:05This is not only the input specification of the background, but also hints at its storage method within the system.

Front-end precise display:stampToDateMagic

However, the time information set by the background is usually stored in the database in the form of timestamps, which is efficient and convenient for machines, but a string of 10 or 13-digit digital timestamps is obviously not intuitive for human readers. To enable users to clearly and accurately read the specific time of content publication or update, AnQiCMS providesstampToDateThis concise and powerful template tag.

stampToDateThe core function of the label is to convert this machine-friendly timestamp into a familiar, readable date and time format. Its usage is very intuitive, usually containing two core parameters: {{stampToDate(时间戳, "格式")}}.

  1. timestampThis is usually the original time data you want to format. In the AnQiCMS content model, the document'sCreatedTime(creation time) andUpdatedTime(Update time) and other fields are provided in the form of timestamps and can be used directly asstampToDatethe first parameter.
  2. FormatThis isstampToDateThe essence of it, it follows the unique time formatting rules of the Go language. It is used by many other programming languagesYYYY-MM-DDThis placeholder is different, Go language uses a specific reference time point-2006年01月02日 15时04分05秒And its corresponding number is used as a template. For example, if you want to display the year, you write2006If you want to display the month, write01. It is a very flexible and powerful formatting method.

Understanding this formatting rule in Go language is crucial:

  • year:2006
  • month:01(or)Janstands for English abbreviation,Januaryindicating the English full name)
  • Day:02(or)_2indicating the day of a single number, preceded by a space)
  • hour:15(24-hour format) or03(12-hour format)
  • minute:04
  • seconds:05
  • milliseconds:.000
  • AM/PM:PM(combined with 12-hour format)
  • Time Zone:MST(or)Z07:00Represents UTC offset)

By combining these reference values, you can customize almost any desired date and time display format.

Practical exercise: Applying in AnQiCMS template

Now, let's look at specific template code examples,stampToDateHow to achieve accurate display of the publication time in the AnQiCMS front-end template.

Scenario one: Display the publication time on the article detail page

Assuming we want to display the publication time on the article detail page (usually correspondingarchiveDetailtags) of the article. The document'sCreatedTimeThe field will provide the timestamp we need.

{# 获取当前文章的发布时间戳,并格式化为 "年-月-日 时:分" #}
<div>
    文章发布时间:
    {% archiveDetail articleCreatedTime with name="CreatedTime" %}
    {{stampToDate(articleCreatedTime, "2006-01-02 15:04")}}
</div>

{# 如果您希望显示为中文格式的日期 #}
<div>
    发布日期:
    {% archiveDetail articleCreatedTime with name="CreatedTime" %}
    {{stampToDate(articleCreatedTime, "2006年01月02日")}}
</div>

{# 或者需要更详细的中文时间,精确到秒 #}
<div>
    详细发布时间:
    {% archiveDetail articleCreatedTime with name="CreatedTime" %}
    {{stampToDate(articleCreatedTime, "2006年01月02日 15时04分05秒")}}
</div>

{# 甚至只显示月份和日期 #}
<div>
    月日:
    {% archiveDetail articleCreatedTime with name="CreatedTime" %}
    {{stampToDate(articleCreatedTime, "01-02")}}
</div>

In this example, we first usearchiveDetailThe tag obtained the current document'sCreatedTime(Timestamp), then pass it as the first argument tostampToDateand provides different Go language time formatting strings as needed.

Scenario two: Display the publication time of each article on the article list page

When you need to display the publication time of multiple articles on an article list page (usually correspondingarchiveListtag) to display the publication time of multiple articles,stampToDateit also applies. InforWhen iterating over the list of articles, each article'sCreatedTimewill pass throughitem.CreatedTimeRetrieve.

`twig {% archiveList archives with type=“page” limit=“10” %}

{% for item in archives %}
    <div class="article-

Related articles

Can `stampToDate` format timestamps into ISO 8601 standard format (such as "YYYY-MM-DDTHH:MM:SSZ")?

As an experienced website operation expert who deeply understands the operation of AnQiCMS, I fully understand the importance of time formatting, especially standardized time formats, in content management.Today, let's delve into the `stampToDate` tag of Anqi CMS to see if it can format timestamps into ISO 8601 standard format, such as the `"YYYY-MM-DDTHH:MM:SSZ"` we often see.### AnQi CMS's `stampToDate`: Easily format timestamps to ISO

2025-11-07

Are there any special considerations when using the `stampToDate` tag in the Anqi CMS multi-site environment?

As an experienced website operation expert, I have accumulated rich experience in the practical application of AnQiCMS, especially feeling deeply about the flexible use of template tags.Today, let's delve deeply into the commonly used `stampToDate` tag, and when it is called in the multi-site environment of AnQiCMS, are there any points that need special attention?AnQiCMS is an efficient and customizable enterprise-level content management system, and its multi-site management function is one of its core advantages.It allows users to manage multiple independent sites on a unified backend

2025-11-07

How to get and display the day of the week corresponding to the timestamp in the AnQi CMS template using `stampToDate`?

## Unlock Time Magic: Displaying the Weekday Easily in Anqi CMS Templates As an experienced website operations expert, I am well aware of the importance of content timeliness and presentation methods for user experience and information communication.In AnQiCMS (AnQiCMS) such a flexible and efficient content management system, we can not only easily manage diverse content, but also finely control every detail of content display through its powerful template engine.

2025-11-07

If the `archive.CreatedTime` field is empty, how will `stampToDate` handle and display?

As an experienced website operations expert, I know that the timeliness of content is crucial for user experience and SEO optimization.AnQiCMS (AnQiCMS) with its powerful content management and flexible template system, allows us to efficiently handle these requirements.In content display, handling the publication time is a common and critical link, we usually use the `stampToDate` template tag to format the timestamp data from the backend into a user-friendly date and time format.

2025-11-07

Can the `stampToDate` label handle the millisecond precision of Unix timestamps?

In a content management system, the accurate display of time is crucial, especially when dealing with user behavior, data logs, or the release of specific events.AnQiCMS as a powerful content management system based on the Go programming language provides rich template tags to meet various content display needs, among which the `stampToDate` tag is a powerful tool for formatting timestamps.However, whether this tag can handle the millisecond level precision of Unix timestamps is a concern for many operators and developers.We can see from the official documentation of AnQiCMS

2025-11-07

How to format output with `stampToDate` and then define a variable with `with` tag for reuse?

Dear Anqi CMS operation partners, hello! As an expert who deeply understands the integration of content operation and technology, I know the value of an efficient and flexible content management system for our daily work.AnQi CMS, with its high-performance architecture in Go language and Django-style template engine, undoubtedly provides us with powerful content display capabilities.Today, let's delve into a common and practical little trick in template design: how to cleverly define variables using the `with` tag after formatting output time with `stampToDate`

2025-11-07

How to ensure that the time zone is displayed as local time instead of UTC time when the `stampToDate` label formats time?

AnQiCMS (AnQiCMS) is an enterprise-level content management system developed based on the Go language, whose powerful template engine enables flexible and diverse content display.In daily content operations, the formatted display of time is a common need, and the `stampToDate` tag is exactly for this purpose.It can convert Unix timestamps into the familiar date and time format.However, many operators may encounter a confusion: why does the time formatted with `stampToDate` sometimes display as UTC time

2025-11-07

Is there an easy way to check if the input timestamp of `stampToDate` is valid in the AnQi CMS template?

As an experienced website operation expert, I am well aware that in a content management system like AnQiCMS, the accuracy and display format of timestamps are crucial for user experience and data presentation.`stampToDate` this powerful label function is undoubtedly a good helper for us to process time information in the template.However, like any tool, it also requires us to use and understand its input requirements correctly.Today, let's delve deeply into a problem that everyone may encounter in the development of Anqi CMS templates: **'In the Anqi CMS template

2025-11-07