Outputting the Article Creation Date (PAGE_CREATED) in Cotonti: All Methods with Examples
This article covers all the main ways to output the article creation date in Cotonti templates.
The examples use the creation date: August 16, 2026, 14:31:30 (Unix timestamp 1755345090).
An empty date is stored as 0 and when formatted gives 01.01.1970 00:00 — therefore, always use PAGE_CREATED_STAMP to check if a date exists.
1. Direct Output of the Ready Date
The tag PAGE_CREATED is already formatted by the function cot_date('datetime_medium', ...).
Syntax:
{PAGE_CREATED}Result for a visitor:
16.08.2026 14:31If the date is empty (0):
01.01.1970 00:002. Output of the Raw Timestamp
The tag PAGE_CREATED_STAMP contains the original numeric value (Unix timestamp). It is used for checks and further processing.
Syntax:
{PAGE_CREATED_STAMP}Result:
17553450903. Using cot_date() with Predefined $Ldt Formats
The cot_date() function accepts a key from the $Ldt array, providing localized output.
3.1. Date only (without time)
Syntax:
{PAGE_CREATED_STAMP|cot_date('date_full', $this)}Result:
16.08.20263.2. Date and time with seconds
Syntax:
{PAGE_CREATED_STAMP|cot_date('datetime_full', $this)}Result:
16.08.2026 14:31:303.3. Time only
Syntax:
{PAGE_CREATED_STAMP|cot_date('time_medium', $this)}Result:
14:313.4. Textual date with month name
Syntax:
{PAGE_CREATED_STAMP|cot_date('date_text', $this)}Result:
16 августа 20263.5. Full textual format with day of week and time
Syntax:
{PAGE_CREATED_STAMP|cot_date('datetime_fulltext', $this)}Result:
Воскресенье, 16 августа 2026 14:31Complete table of $Ldt formats for the Russian language
| Key | Format | Example output for 16.08.2026 14:31:30 |
|---|---|---|
date_full | d.m.Y | 16.08.2026 |
date_medium | m.Y | 08.2026 |
date_short | d.m | 16.08 |
date_text | d F Y | 16 августа 2026 |
date_fulltext | l, d F Y | Воскресенье, 16 августа 2026 |
time_full | H:i:s | 14:31:30 |
time_medium | G:i | 14:31 |
time_short | i:s | 31:30 |
time_text | g:i A | 2:31 PM |
time_fulltext | g:i:s A | 2:31:30 PM |
datetime_full | d.m.Y H:i:s | 16.08.2026 14:31:30 |
datetime_medium | d.m.Y H:i | 16.08.2026 14:31 |
datetime_short | d.m H:i | 16.08 14:31 |
datetime_text | d F Y H:i | 16 августа 2026 14:31 |
datetime_fulltext | l, d F Y H:i | Воскресенье, 16 августа 2026 14:31 |
week_full | o-\WW | 2026-W34 |
week_medium | \WW | W34 |
week_short | \WW-N | W34-7 |
week_text | \WW, l | W34, Воскресенье |
week_fulltext | o-\WW, l | 2026-W34, Воскресенье |
4. Using an Arbitrary PHP Format
Syntax:
{PAGE_CREATED_STAMP|cot_date('Y-m-d H:i:s', $this)}Result:
2026-08-16 14:31:30Any format supported by the PHP date() function can be used.
5. Converting Timestamp to MySQL Date (cot_stamp2date)
The function returns only the date in YYYY-MM-DD format (without time).
Syntax:
{PAGE_CREATED_STAMP|cot_stamp2date($this)}Result:
2026-08-166. Conditional Output Only for Non‑Empty Dates
Since a zero timestamp (0) when formatted gives “01.01.1970”, use PAGE_CREATED_STAMP for checking.
6.1. With the ready value PAGE_CREATED
Syntax:
<!-- IF {PAGE_CREATED_STAMP} -->
<span>Creation date: {PAGE_CREATED}</span>
<!-- ENDIF -->Result when date is not empty:
Creation date: 16.08.2026 14:31Result when date is empty:
(nothing is displayed)
6.2. With a custom format
Syntax:
<!-- IF {PAGE_CREATED_STAMP} -->
{PAGE_CREATED_STAMP|cot_date('date_full', $this)}
<!-- ENDIF -->Result when date is not empty:
16.08.20267. Legacy Tags (if legacyMode is enabled)
If legacyMode is enabled in the Cotonti settings, the following tags are additionally available:
PAGE_DATE— analogue ofPAGE_CREATEDPAGE_DATE_STAMP— analogue ofPAGE_CREATED_STAMP
Usage example:
{PAGE_DATE_STAMP|cot_date('d.m.Y', $this)}Result:
16.08.20268. Global Format Change via $Ldt
By default, PAGE_CREATED is built using $Ldt['datetime_medium'].
To change the format for all pages at once, override this key in your theme's or plugin's language file.
Example (theme.en.lang.php):
$Ldt['datetime_medium'] = 'Y-m-d H:i';After that, the direct output {PAGE_CREATED} will yield:
2026-08-16 14:319. Relative Time (optional)
To display “X ago”, the cot_build_timegap() function is used, but calling it in a template with two arguments is difficult. Usually this is done in a PHP plugin:
$relative = cot_build_timegap(Cot::$sys['now'], $page_data['page_date']);This method is not used for PAGE_CREATED in a plain template.
Summary
| Method | Syntax | Result |
|---|---|---|
| Ready value | {PAGE_CREATED} | 16.08.2026 14:31 |
| Date only | {PAGE_CREATED_STAMP|cot_date('date_full', $this)} | 16.08.2026 |
| Date and time with seconds | {PAGE_CREATED_STAMP|cot_date('datetime_full', $this)} | 16.08.2026 14:31:30 |
| Time only | {PAGE_CREATED_STAMP|cot_date('time_medium', $this)} | 14:31 |
| Textual date | {PAGE_CREATED_STAMP|cot_date('date_text', $this)} | 16 августа 2026 |
| Full textual format | {PAGE_CREATED_STAMP|cot_date('datetime_fulltext', $this)} | Воскресенье, 16 августа 2026 14:31 |
| Arbitrary PHP format | {PAGE_CREATED_STAMP|cot_date('Y-m-d H:i:s', $this)} | 2026-08-16 14:31:30 |
| MySQL date | {PAGE_CREATED_STAMP|cot_stamp2date($this)} | 2026-08-16 |
| Conditional output | <!-- IF {PAGE_CREATED_STAMP} --> ... <!-- ENDIF --> | Depends on content |