Showing dates and times in a different format

CoTemplate `cot_date` callback

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  2011-10-12 13:56

Very useful information, thanks!

2. JIabs  2011-10-21 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  2011-11-10 17:31

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

4. Argont  2023-09-20 16:37

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

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

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

Only registered users can post new comments