From 084e96417d7d43776d64667b41eabbae6c98107f Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Mon, 21 Sep 2026 11:05:27 +0200 Subject: [PATCH] Use German time for PHP and the database session The bot turns raid and event times into timestamps as German time, but the website formatted them in the hoster's default timezone (UTC). A raid set to 9:00 therefore showed as 7:00 during summer time. The edit form was prefilled with that wrong time, so saving a raid again would really move it. PHP now uses Europe/Berlin, and each database connection sets the same offset, so NOW() and CURRENT_TIMESTAMP match. The offset follows summer/winter time automatically. Co-Authored-By: Claude Opus 5 --- includes/bootstrap.php | 6 ++++++ includes/db.php | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/includes/bootstrap.php b/includes/bootstrap.php index 5d6471b..5190dba 100644 --- a/includes/bootstrap.php +++ b/includes/bootstrap.php @@ -9,6 +9,12 @@ ini_set('display_errors', '0'); // und dann Umlaute (oe/ae/ue) kaputt macht. Deshalb hier explizit erzwingen. ini_set('default_charset', 'UTF-8'); mb_internal_encoding('UTF-8'); + +// Alle Zeiten in deutscher Zeit. Der Bot rechnet Raid- und Event-Zeiten ebenfalls als deutsche +// Zeit um. Ohne diese Zeile nimmt PHP die Zeitzone des Hosters (oft UTC) - dann erscheint ein +// Raid um 9 Uhr auf der Website als 7 Uhr (Sommerzeit), und beim naechsten Bearbeiten wuerde +// er sogar auf 7 Uhr verschoben. +date_default_timezone_set('Europe/Berlin'); header('Content-Type: text/html; charset=UTF-8'); if (session_status() !== PHP_SESSION_ACTIVE) { diff --git a/includes/db.php b/includes/db.php index bec2fd4..e557767 100644 --- a/includes/db.php +++ b/includes/db.php @@ -26,6 +26,10 @@ function db(): PDO http_response_code(500); exit('Datenbankverbindung fehlgeschlagen. Bitte config.php prüfen.'); } + + // NOW() und CURRENT_TIMESTAMP in derselben Zeitzone wie PHP (deutsche Zeit inkl. + // Sommerzeit). Als Versatz, weil viele Hoster die Zeitzonen-Namen in MySQL nicht geladen haben. + $pdo->exec("SET time_zone = '" . (new DateTimeImmutable('now', new DateTimeZone(date_default_timezone_get())))->format('P') . "'"); } return $pdo;