The browser timezone isn’t passed to the browser so you have to do it in javascript:
//--------------------------------------------------
//----- CONVERT UTF DATETIME TO LOCAL TIMEZONE -----
//--------------------------------------------------
//E.g. <span class="ShowInLocalDatetime">2028-12-14 23:50:00</span>
$HtmlOutput .= <<<_END
Example: <span class="ShowInLocalDatetime">2028-12-14 23:50:00</span><br>
<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;
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through resources like this. We hope you find it helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support here. If you need help with a problem please use one of the many online forums.