Displaying the creation date of an article in Cotonti: all methods in Examples

A complete list of modifications to the PAGE_CREATED tag in Cotonti: direct output, format change, timestamp, conditional output, and global configuration via $Ldt.

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:31

If the date is empty (0):

01.01.1970 00:00

2. 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:

1755345090

3. 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.2026

3.2. Date and time with seconds

Syntax:

{PAGE_CREATED_STAMP|cot_date('datetime_full', $this)}

Result:

16.08.2026 14:31:30

3.3. Time only

Syntax:

{PAGE_CREATED_STAMP|cot_date('time_medium', $this)}

Result:

14:31

3.4. Textual date with month name

Syntax:

{PAGE_CREATED_STAMP|cot_date('date_text', $this)}

Result:

16 августа 2026

3.5. Full textual format with day of week and time

Syntax:

{PAGE_CREATED_STAMP|cot_date('datetime_fulltext', $this)}

Result:

Воскресенье, 16 августа 2026 14:31

Complete table of $Ldt formats for the Russian language

KeyFormatExample output for 16.08.2026 14:31:30
date_fulld.m.Y16.08.2026
date_mediumm.Y08.2026
date_shortd.m16.08
date_textd F Y16 августа 2026
date_fulltextl, d F YВоскресенье, 16 августа 2026
time_fullH:i:s14:31:30
time_mediumG:i14:31
time_shorti:s31:30
time_textg:i A2:31 PM
time_fulltextg:i:s A2:31:30 PM
datetime_fulld.m.Y H:i:s16.08.2026 14:31:30
datetime_mediumd.m.Y H:i16.08.2026 14:31
datetime_shortd.m H:i16.08 14:31
datetime_textd F Y H:i16 августа 2026 14:31
datetime_fulltextl, d F Y H:iВоскресенье, 16 августа 2026 14:31
week_fullo-\WW2026-W34
week_medium\WWW34
week_short\WW-NW34-7
week_text\WW, lW34, Воскресенье
week_fulltexto-\WW, l2026-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:30

Any 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-16

6. 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:31

Result 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.2026

7. Legacy Tags (if legacyMode is enabled)

If legacyMode is enabled in the Cotonti settings, the following tags are additionally available:

  • PAGE_DATE — analogue of PAGE_CREATED
  • PAGE_DATE_STAMP — analogue of PAGE_CREATED_STAMP

Usage example:

{PAGE_DATE_STAMP|cot_date('d.m.Y', $this)}

Result:

16.08.2026

8. 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:31

9. 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

MethodSyntaxResult
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

Back to top

3 minutes read Sodium Carbonate

Comments (0)

No comments yet
Only registered users can post new comments

Page Discussion in Telegram

Content author

webitproff

Online

Sodium Carbonate

Last logged: 2026-08-17 01:24

  • Page published: 2026-08-16 22:31
  • Last update: 2026-08-16 23:00
  • Language:

Связанные статьи