Showing dates and times in a different format

Документація / Швидка допомога / 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  12.10.2011 13:56

Very useful information, thanks!

2. JIabs  21.10.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.11.2011 17:31

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

4. Argont  20.09.2023 16:37

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

5. Alex300  03.10.2023 17:56
{PAGE_ROW_DATE_STAMP|cot_date('Y-m-dTH:i:s', $this)}

Как то так. Смотрите

Всього: 5, на сторінці: 5

Додавання комментарів доступно лише зареєстрованим користувачам