From df285a6f002065ee7ce651895c6fa627eabeb3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Tue, 16 Dec 2025 10:19:45 +0100 Subject: [PATCH 1/2] Added mention about the date filters --- .../date_twig_filters.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/templating/twig_function_reference/date_twig_filters.md b/docs/templating/twig_function_reference/date_twig_filters.md index 64b4e88b46..88cfab623f 100644 --- a/docs/templating/twig_function_reference/date_twig_filters.md +++ b/docs/templating/twig_function_reference/date_twig_filters.md @@ -25,3 +25,33 @@ The filters also accept an optional `timezone` parameter for displaying date and ``` html+twig {{ content.contentInfo.publishedDate|ibexa_short_datetime('PST') }} ``` + +## Considerations for usage outside back office + +The filters rely on user preferences. +When the preferences are not set, for example for logged out users, the filters fallback to a default date format. +In case of some filters, the fallback date format contains locale-aware fragments, for example: full name of the month or day. +When combined with [reverse proxies like Varnish or Fastly](http_cache.md), it's possible to cache a localized version of a date and display it to other users, even if they're not using the same locale. + +Consider these alternatives: + +- Use Twig's built-in `date` filter with a fixed, locale-indenepdent format + + ``` html+twig + {{ content.contentInfo.publishedDate|date('Y-m-d H:i:s') }} + ``` + +- Use ESI for dynamic rendering of the date + + ``` html+twig + {{ render_esi(controller('App\\Controller\\CustomDateController::format', { + 'date': content.contentInfo.publishedDate + })) }} + ``` + + Don't cache the ESI response. + By implementing this solution, you can keep the date format locale-aware. + +- Client-side JavaScript formatting + +For more information, see [HTTP Cache](http_cache.md) and [Delivering personalized responses](context_aware_cache.md#personalize-responses). From 51ab23863c13145452c73516ce8e721e42a387ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 17 Dec 2025 11:45:35 +0100 Subject: [PATCH 2/2] Update docs/templating/twig_function_reference/date_twig_filters.md Co-authored-by: Konrad Oboza --- docs/templating/twig_function_reference/date_twig_filters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templating/twig_function_reference/date_twig_filters.md b/docs/templating/twig_function_reference/date_twig_filters.md index 88cfab623f..622bc96ffe 100644 --- a/docs/templating/twig_function_reference/date_twig_filters.md +++ b/docs/templating/twig_function_reference/date_twig_filters.md @@ -35,7 +35,7 @@ When combined with [reverse proxies like Varnish or Fastly](http_cache.md), it's Consider these alternatives: -- Use Twig's built-in `date` filter with a fixed, locale-indenepdent format +- Use Twig's built-in `date` filter with a fixed, locale-independent format ``` html+twig {{ content.contentInfo.publishedDate|date('Y-m-d H:i:s') }}