How to use the `stampToDate` formatted date in the HTML `datetime` attribute to improve SEO?

Calendar 👁️ 68

Security CMS Practical Guide:stampToDateWith HTMLdatetime: How to give wings to your website's SEO?

As an experienced website operations expert, I know that every detail may be the key to a website standing out in the increasingly fierce internet competition.For SEO, content quality is indeed the core, but optimization at the technical level should not be ignored either.Today, let's delve into a practical and SEO-boosting trick in AnQiCMS (AnQiCMS): how to cleverly utilizestampToDateApply the formatted date to the HTML'sdatetimeProperty.

Since its inception, AnQi CMS has integrated "SEO-friendly" into its design genes.From flexible pseudo-static rules, to comprehensive TDK (Title, Description, Keywords) management, to advanced SEO tools such as Sitemap generation and link push, all reflect the determination to help users achieve better visibility in search engines.On time information processing, AnQiCMS also provides strong support, such as its "Time Factor-Scheduled Publication Function", making content operation more flexible.And today we will talk about the art of formatting time information on the page, as well as how it communicates at a deeper level with search engines.

Identifying the value of time: Why should date information be treated specially?

On our website, dates and times are ubiquitous elements, such as the publication time of articles, the time products are listed, and the deadline for events.For users, a clear and readable date can help them quickly judge the timeliness of information;But for search engines, it is just text like "October 26, 2023", which humans can understand, but machines may not be able to accurately interpret its inherent meaning, especially in cross-language and cross-cultural environments.

This raises a core question: How can we ensure that the user's reading experience is not compromised while also allowing search engines to accurately and correctly understand the time information on the page? The answer lies in the introduction of HTML5.<time>elements anddatetimeProperty.

Of Security CMSstampToDate: magic stick of timestamp

The Anqi CMS usually stores time information for dynamic content in the form of Unix timestamps. For example, when we call the document details, archive.CreatedTimeandarchive.UpdatedTimeThe field returns a 10-digit timestamp. These original timestamps are difficult for users to understand as they are a sequence of numbers, so we need to format them.

At this point, the template engine of Anqi CMS comes into play, providing a very convenient timestamp formatting tag:stampToDate. This tag is like a 'magic wand' that can transform the cold timestamp into any date and time format we need. Its usage is very intuitive:{{stampToDate(时间戳, "格式")}}.

This "format" parameter is particularly powerful, as it follows the Golang (the development language of AnQi CMS) time formatting rules, meaning you can precisely define the output year, month, day, hour, minute, second, and even the day of the week. For example,"2006-01-02"Can be formatted as "2023-10-26""2006年01月02日 15:04"It can be formatted as

HTMLdatetimeProperty: The exclusive translator of the search engine

NowstampToDateWe can easily display beautiful dates for users. But to further improve SEO, we need to introducedatetimeProperty. This property is specifically used for<time>Tag, its purpose is to provide a machine-readable date or time format, usually followingISO 8601 standardformat.

Then, put the formatted date intodatetimeWhat benefits does this attribute have for SEO?

  1. Enhance the search engine understanding:Search engines' crawlers and algorithms will readdatetimeThe standardized date in the attribute. This is like providing a 'personal translator' for search engines, ensuring that it can accurately understand the publication or update time of the content, regardless of the human-readable format displayed on the page.
  2. Optimize the timeliness judgment of the content:For news, blogs, events, and other content that requires timeliness, search engines will judge the freshness of the content based ondatetimeattributes. If your content is frequently updated, make suredatetimeThe attribute reflectsUpdatedTimewhich will help search engines more accurately evaluate whether your content is still valuable.
  3. increase the opportunity to get rich text summaries (Rich Snippets):In some cases, providing structured date information (especially when combined with Schema Markup) can help your page display as rich text snippets in search results, such as search results with additional information like publication dates, event dates, etc., which can significantly increase click-through rates.
  4. Improve accessibility:Although it is not a direct SEO benefit, for users who use screen readers,<time datetime="...">tags can better convey time information, enhancing the overall user experience of the website.

stampToDatewithdatetimeThe Perfect Combination

Now, let's take a look at how to seamlessly combine these two in Anqi CMS templates to achieve dual optimization of date information:

Assuming we want to display the publication time of a document detail page while considering both user reading and search engine understanding, we can write the template code in this way:

{# 获取当前文档的发布时间戳 #}
{% archiveDetail archiveCreatedTime with name="CreatedTime" %}

<p>发布于
    <time datetime="{{ stampToDate(archiveCreatedTime, "2006-01-02T15:04:05Z07:00") }}">
        {{ stampToDate(archiveCreatedTime, "2006年01月02日") }}
    </time>
</p>

{# 如果是更新时间,操作类似 #}
{% archiveDetail archiveUpdatedTime with name="UpdatedTime" %}
<p>最后更新于
    <time datetime="{{ stampToDate(archiveUpdatedTime, "2006-01-02T15:04:05Z07:00") }}">
        {{ stampToDate(archiveUpdatedTime, "2006年01月02日 15:04") }}
    </time>
</p>

In this code snippet, we did several things:

  1. By{% archiveDetail ... %}The tag obtained the document's creation timestamp (archiveCreatedTime)
  2. In<time>Inside the tag, we used stampToDateFormat a user-friendly date, for example “October 26, 2023”.
  3. The most critical thing is, in<time>label'sdatetimethe property, we used againstampToDateThis time is according to the ISO 8601 standard("2006-01-02T15:04:05Z07:00"corresponding toYYYY-MM-DDTHH:MM:SSZof whichZ07:00Indicates time zone information) to format dates and times. This way, search engines can accurately identify this standardized time.

In this way, we not only provide visitors with clear and easy-to-understand date information, but also provide search engines with accurate, machine-readable data, thereby greatly optimizing the page's SEO performance without affecting the user experience.The strength and flexibility of AnQi CMS, precisely through these fine features, help our website go further in the digital world.


Frequently Asked Questions (FAQ)

Q1: What is a Unix timestamp? Why does Anqi CMS use it?A1: Unix timestamp is the number of seconds elapsed since 00:00:00 UTC/GMT on January 1, 1970, and is typically a 10-digit or 13-digit integer.The AnQi CMS uses Unix timestamps to store time because it is an internationally standardized, time zone-independent, easy-to-calculate and store time representation.This unified format avoids confusion caused by different time zones and date formats, which is convenient for internal processing and cross-platform interaction.

Q2:datetimeAre there strict requirements for the date format of properties? Which one should be used?A2: Yes,datetimeThe date format of the attribute is strictly required and it needs to follow the ISO 8601 standard. The most common formats include:

  • Only the date:YYYY-MM-DD(For example:)

Related articles

How to flexibly choose to display the date or time part in `stampToDate` instead of a fixed format?

## Fine control of time display: The secret manual of flexible application of `stampToDate` in AnQi CMS In website operation, the display of time information seems ordinary, but it contains a lot of knowledge to improve user experience and optimize content presentation.AnQi CMS knows this, and has provided a powerful and flexible timestamp formatting tool for webmasters —— `stampToDate`.Many new operators may be puzzled, as this function seems to always output a fixed date and time format, but in fact, by skillfully using its 'format' parameter, you can easily achieve displaying only the date

2025-11-07

Does the `stampToDate` tag have a default output format when no format string is provided?

As an experienced website operations expert, I fully understand the importance of handling time data in content management systems, especially ensuring that they are presented in the way we expect.AnQiCMS (AnQiCMS) has fully considered flexibility and efficiency in the design of template tags, and the `stampToDate` tag is a typical representative.Today, let's delve into a common question about this tag: When no format string is provided, will the `stampToDate` tag have a default output format?###

2025-11-07

How to use `stampToDate` to output the countdown of 'X days until an event' in the template?

## Tips for Anqi CMS Template: Creating an Eye-Catching Countdown Effect for "X Days Until an Event" In today's fast-paced online environment, effective content operation is inseparable from dynamic interaction with users.A well-designed website that not only provides rich information but also enhances user engagement and conversion rates through some clever dynamic elements, such as countdowns.No matter if it's a new product launch, event preview, or an important milestone reminder, a striking countdown can inject vitality into your website and create a sense of urgency.

2025-11-07

How does the performance of `stampToDate` in Anqi CMS template look, will it affect the page loading speed?

## The `stampToDate` in Anqi CMS template: Will it slow down the page loading speed?As an experienced website operations expert, I am well aware that page loading speed is crucial for user experience and search engine optimization.When a template includes some data processing tags, many operators will inevitably have doubts: will this function affect website performance?Today, let's talk about a commonly used and practical tool in Anqi CMS template - the `stampToDate` tag, and delve into its performance in page loading speed

2025-11-07

In AnQiCMS, can the `stampToDate` tag handle date display habits of different regions (such as China and the United States)?

Unlock AnQiCMS `stampToDate`: Easily Master Global Date Display Habits In the wave of global content operations, the subtle differences in date and time formats often become key factors affecting user experience.A website that can intelligently adjust the date display according to the visitor's regional habits will undoubtedly greatly enhance its professionalism and user-friendliness.

2025-11-07

What is the main difference between the `now` tag and the `stampToDate` tag in the time display in `tag-system.md`?

As an experienced website operations expert, I am well aware that how to flexibly and accurately display time information in a content management system is crucial for the vitality of website content and user experience.AnQiCMS (AnQiCMS) takes this point into full consideration in the design of template tags, providing various methods to handle time.Today, let's delve into two commonly used and easily confused tags - the `now` tag and the `stampToDate` tag, analyzing their main differences in time display.

2025-11-07

How to perform security filtering on the date string generated by the `stampToDate` tag to prevent XSS attacks?

As an experienced website operation expert, I am happy to give you a detailed explanation of how to ensure the security of the date string generated by the `stampToDate` tag in AnQiCMS, effectively preventing XSS attacks. --- ### Ensure Security: How to effectively prevent XSS attacks in the date string generated by the `stampToDate` tag in AnQiCMS In the template development of AnQiCMS, the `stampToDate` tag is a powerful helper for us to process timestamps and format them into readable date strings.

2025-11-07

How to display the current website's name and Logo in Anqi CMS template?

As an experienced website operations expert, I am well aware of the importance of a website's name and logo in brand image and user recognition.In a powerful and flexible content management system like AnQiCMS, presenting these core brand elements in the website template not only enhances professionalism but also helps with search engine optimization (SEO).Today, I will give a detailed explanation of how to easily display the current website name and logo in AnQiCMS templates, making your brand shine in the eyes of users.--- ### AnQi CMS Template

2025-11-07