The timeliness and readability of website content largely depend on the accuracy and beauty of date and time information.AnQi CMS is an efficient content management system that provides flexible tags and filters to help us easily implement personalized date and time stamp displays, making your website content more closely aligned with user habits and enhancing the overall reading experience.This article will delve into how to skillfully use these features in Anqi CMS to convert original time data into a clear and understandable display format.

Understanding date and time data in AnQi CMS

In AnQi CMS, the creation time of documents (CreatedTime)、Update Time(UpdatedTime) and such time information are usually displayed asUnix timestampStored in the form of a format in the database. This numeric format is convenient for internal processing and storage within the system, but when displayed on the front end, we need to convert it to a date and time format that users are accustomed to, such as "2023 October 26 10:30:00".

Core tool:stampToDateTag

AnQi CMS provides special formatting for timestampstampToDateLabel, it is simple and intuitive, powerful, and the preferred choice for handling timestamp display.

The basic usage is:{{stampToDate(时间戳, "格式")}}.

  • timestampIt refers to a 10-digit Unix timestamp, for example.1609470335. This is the information you obtained from various tags (such asarchiveDetail/archiveList) obtained.CreatedTimeorUpdatedTimefrom the values of these fields.
  • FormatThis isstampToDateThe most flexible part of the label. It follows the unique time formatting rules of the Go language. Unlike the commonYYYY-MM-DDpattern, the Go language uses a fixed reference time -“January 2, 2006, 3:04:05 PM -0700 MST”Define the format. Just use the corresponding number or English word in this reference time to represent the year, month, day, hour, minute, and second you want.

For example:

  • Display "Year-Month-Day", the format string is"2006-01-02".
  • Display "Year/Month/Day Time:Minute", the format string is"2006/01/02 15:04".
  • Display "Month-Day Time:Minute", the format string is"01-02 15:04".
  • Would like to display "English month abbreviation Day, Year", the format string is"Jan 02, 2006".

**stampToDate