Of course! Let's break down the dede:from_unixtime tag in DedeCMS (织梦内容管理系统).

What is dede:from_unixtime?
In simple terms, dede:from_unixtime is a DedeCMS template tag used to convert a Unix timestamp into a human-readable date and time format.
Why is this needed?
- Unix Timestamp: This is a number representing seconds since January 1, 1970 (UTC). It's how databases (like MySQL) and many programming systems store dates and times because it's efficient for sorting and calculations.
- Human-Readable Format: Website visitors don't see timestamps like
1678886400. They want to seeMarch 15, 2025or2025-03-15 10:30:00.
The dede:from_unixtime tag acts as a translator, making the date stored in your database easy for users to understand.
Syntax and Parameters
The basic syntax of the tag is:
{dede:from_unixtime timestamp='你的时间戳' format='日期格式' /}
It has two main parameters:

timestamp (Required)
This is the Unix timestamp you want to convert. It's not always a static number. It's most commonly used to display the publication time of an article.
- Common value:
[field:pubdate /]or[field:senddate /][field:pubdate /]: The article's publication date (from thepubdatefield in thedede_archivestable).[field:senddate /]: The article's submission date (from thesenddatefield).
Example:
{dede:from_unixtime timestamp='[field:pubdate /]' /}
format (Optional)
This parameter controls the output format of the date and time. If you don't provide it, DedeCMS uses a default format (usually Y-m-d H:i:s).
Here are the most common format codes you can use:

| Code | Description | Example Output |
|---|---|---|
Y |
Four-digit year | 2025 |
y |
Two-digit year | 23 |
m |
Two-digit month (with leading zero) | 03 |
n |
Month without leading zero | 3 |
d |
Two-digit day of the month | 15 |
j |
Day of the month without leading zero | 15 |
H |
24-hour format (with leading zero) | 14 |
h |
12-hour format (with leading zero) | 02 |
i |
Minutes (with leading zero) | 05 |
s |
Seconds (with leading zero) | 09 |
F |
Full month name | March |
M |
Three-letter month name | Mar |
D |
Three-letter day name | Tue |
l |
Full day name | Tuesday |
Practical Examples
Let's assume an article's [field:pubdate /] is 1678886400, which corresponds to 2025-03-15 10:30:00.
Example 1: Default Format
If you don't specify a format, it will look like this:
{dede:from_unixtime timestamp='[field:pubdate /]' /}
Output:
2025-03-15 10:30:00
Example 2: Standard Date Format (e.g., for a list)
This is very common for displaying just the date of an article.
{dede:from_unixtime timestamp='[field:pubdate /]' format='Y-m-d' /}
Output:
2025-03-15
Example 3: More Readable Format (e.g., "March 15, 2025")
This is great for improving user experience.
{dede:from_unixtime timestamp='[field:pubdate /]' format='F j, Y' /}
Output:
March 15, 2025
Example 4: Including Time in 12-hour Format
Use this if you want to show AM/PM.
{dede:from_unixtime timestamp='[field:pubdate /]' format='Y-m-d h:i:s A' /}
Output:
2025-03-15 10:30:00 AM
Example 5: Displaying the Update Time
You can use it for other timestamps in the system, like the article's update time (uptime).
更新时间: {dede:from_unixtime timestamp='[field:uptime /]' format='Y-m-d H:i' /}
Output:
更新时间: 2025-03-16 16:45
Common Use Cases in Templates
-
In
article_article.htm(Article Detail Page): Display the article's publication date in a user-friendly way.<div class="article-info"> <span>发布时间:{dede:from_unixtime timestamp='[field:pubdate /]' format='Y-m-d' /}</span> <span>作者:{dede:field name='writer' /}</span> <span>来源:{dede:field name='source' /}</span> <span>点击:{dede:field name='click' /}</span> </div> -
In
list_artlist.htm(Article List Template): Show the date for each article in a list.{dede:list} <li> <a href="[field:arcurl/]">[field:title/]</a> <span class="date">{dede:from_unixtime timestamp='[field:pubdate /]' format='Y-m-d' /}</span> </li> {/dede:list}
Troubleshooting
-
Problem: The tag shows nothing or a strange error.
- Check 1: Make sure the
timestampparameter is correctly set, usually to[field:pubdate /]. Double-check that this field has a value in your database. - Check 2: Ensure you are using the correct DedeCMS tag syntax. The closing is important:
{dede:from_unixtime ... /}.
- Check 1: Make sure the
-
Problem: The date format is wrong.
- Check: Review your
formatstring. Remember that characters like , , , and spaces are treated as literal characters. Use the format codes from the table above correctly. For example,Y-m-dis correct, butY m dwould produce2025 03 15.
- Check: Review your
