Fixes the problem that the user's time zone is not used
authorCyperghost <olaf_schmitz_1@t-online.de>
Tue, 5 Nov 2024 09:27:06 +0000 (10:27 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Tue, 5 Nov 2024 09:27:06 +0000 (10:27 +0100)
See https://github.com/WoltLab/WCF/pull/6042#discussion_r1828441438

wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php

index 9d1718f8843c9a096b296c98e7051b86dc81738e..4477084f78bfffd6daa35d03574041b85f8ec204 100644 (file)
@@ -29,14 +29,16 @@ class DateModifierTemplatePlugin implements IModifierTemplatePlugin
     public function execute($tagArgs, TemplateEngine $tplObj)
     {
         if ($tagArgs[0] instanceof \DateTimeInterface) {
-            $dateTime = $tagArgs[0];
+            $dateTime = clone $tagArgs[0];
         } else {
             $timestamp = \intval($tagArgs[0]);
             $dateTime = new \DateTimeImmutable('@' . $timestamp);
         }
 
         if (!empty($tagArgs[1])) {
-            return $dateTime->format($tagArgs[1]);
+            return $dateTime
+                ->setTimezone(WCF::getUser()->getTimeZone())
+                ->format($tagArgs[1]);
         } else {
             $locale = WCF::getLanguage()->getLocale();
             $timeZone = WCF::getUser()->getTimeZone();