How to use the `stampToDate` filter to format timestamps into readable dates in Json-LD?

Calendar 👁️ 64

Safe CMS: How to cleverly use in Json-LDstampToDateThe filter makes timestamps readable and lively

As an experienced website operation expert, I know that in today's digital marketing era, website content not only needs to attract users but also needs to 'please' search engines.AnQiCMS (AnQiCMS) is an enterprise-level content management system developed based on the Go language, which has become a powerful assistant for many small and medium-sized enterprises and content operation teams with its high efficiency, flexibility, and SEO-friendly features.Among many strategies to improve SEO performance, structured data (Json-LD) plays a crucial role. It helps search engines understand web content more accurately, thereby improving search rankings and display effects.

When configuring JSON-LD structured data, we often encounter situations where we need to handle time information, such as the publication date or update date of an article.These times are usually stored in the database in the form of timestamps (Timestamp), while the Json-LD standard requires dates to be presented in a human-readable and machine-friendly format.This, built-in by AnQi CMSstampToDateThe filter comes in handy, it can easily convert the original timestamp into a date format that conforms to Json-LD specifications.

Understand the integration of Json-LD and AnQi CMS

Json-LD (JSON for Linking Data) is a lightweight linking data format that allows web administrators to embed structured data directly into HTML pages, enabling search engines to understand the relationships and attributes of various entities on the page (such as articles, products, events, etc.).The AnQi CMS has always fully considered SEO optimization from its design, therefore it naturally supports structured data.The system will automatically generate the basic Json-LD for your content, saving you the trouble of manual writing.

However, for some personalized needs, such as showing specific author information, custom image lists, or as we are discussing today, precise control over the date and time format, Anqi CMS provides极高的 flexibility. You can use it in templates by{% jsonLd %}...{% endjsonLd %}Label, to inject or override the default generated Json-LD content.In this custom block, you can define the structured data fields you need as you would write normal JSON, and Anqi CMS will intelligently merge this custom content with the Json-LD generated by the system by default.

Timestamp and readable date: Why is formatting so important?

In AnQi CMS, whether it's theCreatedTime(creation time) or notUpdatedTime(Updated time), these data are stored in the background in the form of 10-digit timestamps.The timestamp is essentially a sequence of numbers that represents the number of seconds from a fixed point in time (usually the Unix epoch, January 1, 1970, 00:00:00 UTC) to a specific time.This format is very efficient for database and program processing, but it is not very intuitive for human reading and search engine parsing.

In JSON-LD and other structured data, date and time information must follow the ISO 8601 standard, for exampleYYYY-MM-DDTHH:MM:SSZThis unified format ensures consistency in the understanding of date and time across different systems and regions, avoiding ambiguity.For search engines, precise and standardized date information helps them determine the freshness, relevance, and position on the timeline of the content, which is particularly crucial for time-sensitive content such as news, blogs, and events.Therefore, converting timestamps into readable standardized dates is an indispensable step to enhance content value and SEO performance.

stampToDateFilter: Date formatting tool for AnQi CMS

To solve the problem of converting timestamps to readable dates, Anqi CMS has built-in a very practicalstampToDateA filter. Its usage is concise and clear, able to directly format a 10-digit timestamp into any date and time format you need.

stampToDateThe basic syntax of the filter is:{{stampToDate(时间戳, "格式")}}.

It should be noted that the "format" section is particularly important. The template engine of AnQi CMS is based on Go language, and its date formatting method also follows the unique style of Go language, namely through a specific reference date——2006-01-02 15:04:05.999999999 -0700 MSTDefine the output format. You do not need to remember this long reference date, just remember the meanings of the various components in it:

  • 2006Represents the year
  • 01Represents the month
  • 02Represents the date
  • 15Represents the hour in 24-hour format
  • 04representing minutes
  • 05representing seconds
  • MSTorZ07:00Represents time zone information (often used in Json-LD)Z07:00Indicates UTC time offset

By combining these numbers, you can flexibly create various date formats. For example:

  • "2006-01-02"It will output.年-月-日such as2023-10-26
  • "2006年01月02日"It will output.2023年10月26日
  • "2006/01/02 15:04"It will output.年/月/日 时:分such as2023/10/26 10:30
  • And for Json-LD, we often need ISO 8601 format, which can be used like this:"2006-01-02T15:04:05Z07:00"It will output something similar2023-10-26T10:30:00+08:00Such standardized date and time.

It is easy to confuse this filter with Anqi CMSdateFilter, but please note,dateThe expected input for the filter is Go languagetime.TimeAn object type, not an original timestamp. Therefore, when processing a 10-digit timestamp directly returned by the database,stampToDateis a more direct and convenient choice.

Integration in Json-LDstampToDate: Practical Example

Now, let's look at a specific example of how to use `stampTo` in a JSON-LD of the typeArticle)

Related articles

How to configure different language versions of Json-LD for AnQiCMS multilingual website?

As an experienced website operation expert, I know that structured data (Structured Data) is of great importance to the performance of a website in search engines, and Json-LD, as a powerful and flexible implementation method, is an indispensable part of our content marketing and SEO strategy.When facing multilingual websites, how to ensure that each language version has accurate Json-LD has become a topic worth in-depth discussion.

2025-11-06

Under a multi-site management model, how can Json-LD custom tags differentiate data from different sites?

In today's highly competitive digital environment, owning multiple websites to cover different brands, product lines, or regional markets has become the norm.AnQiCMS (AnQi CMS) leverages its powerful multi-site management capabilities, providing great convenience for enterprises and content operators.

2025-11-06

How to handle the case where fields in Json-LD are empty or do not exist, to avoid outputting invalid data?

## Website operations expert discusses: How to elegantly handle JSON-LD null values in AnQi CMS to create high-quality structured data In today's digital marketing environment, structured data (JSON-LD) has become a key factor in improving website search engine visibility and obtaining rich media summaries (Rich Snippets).It can help search engines to understand web content more accurately, thus providing users with more accurate search results.AnQiCMS (AnQiCMS) is an efficient content management system tailored for enterprises and content operation teams

2025-11-06

Within the `{% Ld %}` tag, can AnQiCMS template tags be nested to dynamically generate content?

As an experienced website operations expert, I am well aware that effective content management and optimization are the key to success in the increasingly fierce online environment.AnQiCMS (AnQiCMS) takes advantage of its high-performance architecture in the Go language and flexible template system, providing us with an excellent content management experience.Today, let's delve deeply into a topic that many operators and developers are concerned about: Can we nest other AnQiCMS template tags within the `{% Ld %}` tag to dynamically generate content?

2025-11-06

How to use the `if` logical judgment tag to implement conditional output in Json-LD?

As an experienced website operations expert, I fully understand that how to make the website content stand out in the increasingly fierce online competition, and how to be accurately understood and effectively displayed by search engines is the top priority of our work.Structured data (Json-LD) is undoubtedly a tool to enhance website visibility and user experience.However, the content of the website changes constantly, and if Json-LD remains unchanged, it cannot fully utilize its advantages.AnQiCMS (AnQiCMS) is a content management system known for its flexibility and ease of use, deeply understanding this field.It provides a powerful template engine

2025-11-06

Does AnQiCMS's pseudostatic rules affect the generation of link addresses in Json-LD?

As an experienced website operation expert, I know that the SEO performance of a website is the foundation of its success.In this increasingly important era of digital content marketing, the correct use of URL structure, static page configuration, and structured data (such as Json-LD) is all affecting how search engines understand and rank website content.TodayThe answer is affirmative, and this impact is positive and crucial

2025-11-06

How to use the `for` loop tag to generate list or array data in Json-LD (such as comment list)?

Hello everyone, website operators and partners!As an expert with many years of experience in website operation, I am well aware that how to make the website content stand out and be better understood and displayed by search engines is a crucial part of our daily work.AnQiCMS (AnQiCMS) with its powerful functions and flexible customization provides us with many conveniences.

2025-11-06

Does the `Json-LD` custom tag support fetching data from the `diy` custom content tag?

As an experienced website operations expert, I am well aware of the importance of structured data, especially Json-LD, in the context of increasingly refined search engine optimization (SEO) and its impact on the visibility and rich presentation of website content.AnQiCMS (AnQiCMS) as an efficient and flexible content management system naturally also provides us with powerful tools to achieve this goal.

2025-11-06