Of course. The GetDateTimeMK function is a very specific and useful function in the legacy DedeCMS (织梦CMS) templating engine. It's used to format date and time information in a particular, localized way that was common in Chinese web design.

Let's break it down in detail.
What is GetDateTimeMK?
GetDateTimeMK is a DedeCMS custom function (PHP function) designed to be used within DedeCMS templates (*.htm files). Its primary purpose is to take a timestamp and format it into a Chinese-style date and string, which was very popular in the mid-2000s.
It's essentially a specialized formatting tool for dates.
Syntax
The syntax is simple and straightforward:

{dede:field function='GetDateTimeMK(@me)'}
Parameters
@me: This is a special DedeCMS template variable. When used inside a{dede:field}tag,@merefers to the current value of that field. ForGetDateTimeMK,@meis expected to be a Unix timestamp.
How It Works: The Core Logic
The GetDateTimeMK function takes a Unix timestamp and converts it into a string formatted as YYYY年MM月DD日 HH:mm. It's a shortcut for creating a localized, human-readable date.
Let's look at the PHP source code of the function to understand exactly what it does:
// This is the typical PHP code for the function in DedeCMS
function GetDateTimeMK($arcid)
{
// Create a new DateTime object from the timestamp
$dtime = new Date("@$arcid");
// Format the date into the Chinese style
$time = $dtime->format('Y年m月d日 H:i');
return $time;
}
Explanation:
- It receives a timestamp (e.g.,
1625097600). - It uses PHP's
Dateclass (a DedeCMS wrapper forDateTime) to create an object from that timestamp. - It formats the date using the specific format string:
'Y年m月d日 H:i'.Y: 4-digit year (e.g., 2025)m: 2-digit month (e.g., 06)d: 2-digit day (e.g., 25)H: 24-hour format hour (e.g., 14)i: Minutes with leading zeros (e.g., 30)
- The characters
年,月,日, and are literal separators. - It returns the final string, for example:
2025年06月25日 14:30.
Practical Usage Examples
Here are the most common places you'll use GetDateTimeMK in a DedeCMS template.

Example 1: Displaying an Article's Publication Date
This is the most frequent use case. In an article list (arclist.htm) or article detail (article_article.htm) template, you want to show when the article was published.
In arclist.htm (Article List):
<ul>
{dede:arclist titlelen='30' row='10'}
<li>
<a href="[field:arcurl/]">[field:title/]</a>
<span class="date">发布于: {dede:field function='GetDateTimeMK(@me)'/}</span>
</li>
{/dede:arclist}
</ul>
Note: In arclist, the pubdate field is already a timestamp, so @me works perfectly.
In article_article.htm (Article Detail Page):
<div class="article-info">
<span>发布时间:{dede:field.pubdate function='GetDateTimeMK(@me)'/}</span>
<span>作者:{dede:field.writer/}</span>
<span>来源:{dede:field.source/}</span>
</div>
Example 2: Displaying a Comment's Post Time
Similarly, for comments, you can use it to format the dtime field.
In templets/feedback.htm (Comment List):
{dede:feedback}
<div class="comment-item">
<div class="comment-header">
<strong>[field:username function='htmlspecialchars(@me)'/]</strong> 说:
<span class="comment-time">{dede:field.dtime function='GetDateTimeMK(@me)'/}</span>
</div>
<p>[field:msg function='htmlspecialchars(@me)'/]</p>
</div>
{/dede:feedback}
GetDateTimeMK vs. MyDate
It's crucial to understand the difference between GetDateTimeMK and the more general MyDate function, as they are often confused.
| Feature | GetDateTimeMK |
MyDate |
|---|---|---|
| Purpose | Specialized: Formats a date into a single, specific Chinese style. | General Purpose: Formats a date into any custom format you specify. |
| Syntax | {dede:field function='GetDateTimeMK(@me)'} |
{dede:mydate('format-string', @me)} |
| Flexibility | Low. Always outputs YYYY年MM月DD日 HH:mm. |
High. You control the output format. |
| Use Case | When you specifically want the 年月日 format. |
When you need any other format, e.g., Y-m-d, Y/m/d, etc. |
Example with MyDate:
If you wanted to display the date as 2025-06-25, you would use MyDate:
<!-- Using MyDate to get a different format -->
{dede:field.pubdate function='MyDate("Y-m-d", @me)'}
<!-- This would output: 2025-06-25 -->
Modern Considerations and Alternatives
-
Legacy System:
GetDateTimeMKis a hallmark of older DedeCMS versions (from DedeCMS 5.x era). While it still works in modern versions, the trend is to move away from these custom PHP-in-template functions for better security and cleaner code. -
Security: The
function='...'syntax can be a security risk if not properly sanitized, as it allows arbitrary PHP function execution. Modern DedeCMS versions have tightened this, but it's a good practice to be aware of. -
Modern PHP (PHP 8+): If you are modifying PHP files directly (e.g.,
include/taglib/arclist.lib.php), it's better to use modern PHP date/time functions.Old Way (in PHP):
$time = GetDateTimeMK($row['pubdate']);
Modern PHP Way:
// Use date_create() and format() $date = date_create('@' . $row['pubdate']); $time = date_format($date, 'Y年m月d日 H:i'); // Or simply, if you are on PHP 8.0+ $time = date('Y年m月d日 H:i', $row['pubdate']);
Summary
- What it is: A DedeCMS template function to format a Unix timestamp into
YYYY年MM月DD日 HH:mm. - How to use:
{dede:field function='GetDateTimeMK(@me)'}. - Best for: Quickly displaying a localized Chinese date in articles, comments, etc.
- Not for: When you need a custom date format; use
{dede:mydate}instead. - Status: A legacy but still functional part of DedeCMS.
