The browser timezone isn’t passed to the server, so you have to do it in javascript.
Local Date and Time from UTF
//----- CONVERT UTF DATETIME TO BROWSER LOCAL TIMEZONE DATE AND TIME -----
//E.g. <span class="ShowInLocalDatetime">2028-12-14 23:50:00</span>
$HtmlOutput .= <<<_END
<script>
function RenderLocalDatetimes()
{
const elements = document.querySelectorAll(".ShowInLocalDatetime"); /*Get all with class="ShowInLocalDatetime" */
elements.forEach(el => {
let utcString = el.textContent.trim();
if (utcString === '')
return;
utcString = el.textContent.trim().replace(" ", "T") + "Z";
const dt = new Date(utcString);
//Force format: 12 December 2025 23:14
const formatted = dt.toLocaleString("en-GB", {
day: "2-digit",
month: "long",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
hour12: false
}).replace(",", "").replace("at", ""); // remove ',' and 'at' if locale inserts one
el.textContent = formatted;
});
}
// Call it once DOM is ready
document.addEventListener("DOMContentLoaded", RenderLocalDatetimes);
</script>
_END;
Local Date only from UTF
//----- CONVERT UTF DATETIME TO BROWSER LOCAL TIMEZONE DATE ONLY -----
//E.g. <span class="ShowInLocalDate">2028-12-14 23:50:00</span>
$HtmlOutput .= <<<_END
<script>
function RenderLocalDate()
{
const elements = document.querySelectorAll(".ShowInLocalDate"); /*Get all with class="ShowInLocalDate" */
elements.forEach(el => {
let utcString = el.textContent.trim();
if (utcString === '')
return;
utcString = el.textContent.trim().replace(" ", "T") + "Z";
const dt = new Date(utcString);
//Force format: 12 December 2025
const formatted = dt.toLocaleDateString("en-GB", {
day: "2-digit",
month: "long",
year: "numeric"
});
el.textContent = formatted;
});
}
//Call it once DOM is ready
document.addEventListener("DOMContentLoaded", RenderLocalDate);
</script>
_END;
