Showing dates and times in a different format

This page is not translated yet. Showing original version of page. You can sign up and help with translating.

By default, dates and times in Cotonti are formatted in a preconfigured way. While this works out fine in most cases, sometimes you will want to use a different format in your theme. Cotonti provides a simple way to achieve this using CoTemplate callbacks.

{PAGE_ROW_DATE_STAMP|cot_date('d-m-Y', $this)}

The cot_date() function is very similar to the regular date function in PHP, with the addition of localized date formats. These formats are defined in $Ldt in main.en.lang.php. It's recommended to use these formats since they are more flexible. Here's an example:

{PAGE_ROW_DATE_STAMP|cot_date('date_full', $this)}

Here's a list of all the available localized date/time formats (default en_US locale):

Name Format Example
date_full Y-m-d 1988-06-18
date_medium Y-m 1988-06
date_short m-d 06-18
date_text F d, Y June 18, 1988
date_fulltext l, F d, Y Saturday, June 18, 1988
time_full H:i:s 08:45:00
time_medium G:i 8:45
time_short i:s 45:00
time_text g:i A 8:45 AM
time_fulltext g:i:s A 8:45:00 AM
datetime_full Y-m-d H:i:s 1988-06-18 08:45:00
datetime_medium Y-m-d H:i 1988-06-18 08:45
datetime_short m-d H:i 06-18 08:45
datetime_text F d, Y H:i June 18, 1988 08:45
datetime_fulltext l, F d, Y H:i Saturday, June 18, 1988 8:45
week_full o-\WW 1988-W24 *
week_medium \WW W24
week_short \WW-N W24-6
week_text \WW, l W24, Saturday
week_fulltext o-\WW, l 1988-W24, Saturday

* If the ISO week number belongs to the previous or next year, that year is used.

For more information on date/time formatting, see the PHP documentation.


1. Twiebie  12. Oktober 2011, 13:56

Very useful information, thanks!

2. JIabs  21. Oktober 2011, 15:48

Cool, but i think it will be better if admin of site can overwrite these formats by his custom theme|language file, because of update. Is it possible?

(sorry for my english)

3. Trustmaster  10. November 2011, 17:31

It is possible, you can overwrite it in your theme language strings.

4. Argont  20. September 2023, 16:37

по этим форматам дат понятно, а вывести в разметку такого формата?

      "datePublished":"2015-02-05T08:00:00+08:00",
      "dateModified":"2015-02-05T09:20:00+08:00",
5. Alex300  3. Oktober 2023, 17:56
{PAGE_ROW_DATE_STAMP|cot_date('Y-m-dTH:i:s', $this)}

Как то так. Смотрите https://www.php.net/manual/ru/datetime.format.php

Nur registrierte Benutzer können Kommentare schreiben