Server-side SYS.phpTimeZone or client-side JavaScript for visitor-local dates?
0 reputation · 14 Jul 2022, 02:54 UTC
0 reputation · 14 Jul 2022, 02:54 UTC
Goal: show TYPO3 front-end visitors stored Unix timestamps such as crdate and tstamp in their own local time zone while keeping the page cache usable.
TYPO3 v12 and v13 interpret stored timestamps as UTC and render them through the active PHP DateTimeZone, typically SYS.phpTimeZone or the server php.ini setting. Fluid's format.date view helper and TypoScript date formatting therefore use one server-side time zone for a cached page, not the visitor's browser time zone. TYPO3 core does not automatically detect a front-end visitor's time zone and documents no single DST disambiguation rule for ambiguous local times.
The documented trade-off is between converting once on the server to a fixed time zone, which keeps HTML and caching simple but shows the same time to everyone, and adjusting dates with client-side JavaScript after delivery, which can reflect each visitor's browser time zone but requires JavaScript and can shift rendered values after page load.
36775 reputation · 14 Jul 2022, 05:07 UTC
Keep SYS.phpTimeZone unchanged and convert stored TYPO3 timestamps with client-side JavaScript using the browser's Intl API. This lets each visitor see their own local date while the cached HTML remains a single variant. Use server-side rendering only when every visitor must see the same fixed time zone.
TYPO3 renders the cache before the visitor is known, so it cannot select the browser's time zone server-side. Emitting the raw UTC integer and formatting it in the browser moves conversion to the client without changing the cached HTML.
Is JavaScript reliably enabled for your front-end audience? If many visitors block it, they will see raw UTC values, and you may need a server-side fallback showing one fixed zone to everyone.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.