diff --git a/app/src/ViewFunctions/ModifiedTime.php b/app/src/ViewFunctions/ModifiedTime.php index 420636e..4df9780 100644 --- a/app/src/ViewFunctions/ModifiedTime.php +++ b/app/src/ViewFunctions/ModifiedTime.php @@ -5,6 +5,8 @@ declare(strict_types=1); namespace App\ViewFunctions; use App\Config; +use DateTimeImmutable; +use DateTimeZone; use RuntimeException; use Symfony\Component\Finder\SplFileInfo; @@ -26,6 +28,10 @@ class ModifiedTime extends ViewFunction $modifiedTime = lstat($file->getPathname())['mtime']; } - return date($this->config->get('date_format'), $modifiedTime); + $date = DateTimeImmutable::createFromTimestamp($modifiedTime)->setTimezone( + new DateTimeZone($this->config->get('timezone')) + ); + + return $date->format($this->config->get('date_format')); } } diff --git a/tests/ViewFunctions/ModifiedTimeTest.php b/tests/ViewFunctions/ModifiedTimeTest.php index dc8cb53..4c9f200 100644 --- a/tests/ViewFunctions/ModifiedTimeTest.php +++ b/tests/ViewFunctions/ModifiedTimeTest.php @@ -16,6 +16,8 @@ class ModifiedTimeTest extends TestCase #[Test] public function it_can_return_the_modified_time_for_a_file(): void { + $this->container->set('timezone', 'UTC'); + $file = $this->createMock(SplFileInfo::class); $file->method('getMTime')->willReturn(516976496);