DateTime format based on TIMEZONE #1044

This commit is contained in:
jokob-sk
2025-05-10 15:23:02 +10:00
parent 01f7a18dce
commit 03822ac8fa
5 changed files with 53 additions and 3 deletions

View File

@@ -353,6 +353,28 @@ function getLangCode() {
// String utilities
// -----------------------------------------------------------------------------
function localizeTimestamp(result)
{
// contains TZ in format Europe/Berlin
tz = getSetting("TIMEZONE")
const date = new Date(result); // Assumes result is a timestamp or ISO string
const formatter = new Intl.DateTimeFormat('default', {
timeZone: tz,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false // change to true if you want AM/PM format
});
return formatter.format(date);
}
// ----------------------------------------------------
/**
* Replaces double quotes within single-quoted strings, then converts all single quotes to double quotes,