From 2bac42522d61e86433e48e461623be943f9577e2 Mon Sep 17 00:00:00 2001 From: Micheal Mand Date: Mon, 13 Apr 2020 14:07:15 -0600 Subject: [PATCH] Add ability to set Timezone in config --- .env.example | 1 + app/config/app.php | 8 ++++++++ app/src/Factories/TwigFactory.php | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/.env.example b/.env.example index 5e78262..23fb9b6 100644 --- a/.env.example +++ b/.env.example @@ -14,5 +14,6 @@ HIDE_APP_FILES=true HIDE_VCS_FILES=true DATE_FORMAT="Y-m-d H:i:s" +TIMEZONE="UTC" MAX_HASH_SIZE=1000000000 diff --git a/app/config/app.php b/app/config/app.php index 07fef6b..5cfaf39 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -119,6 +119,14 @@ return [ */ 'date_format' => Helpers::env('DATE_FORMAT', 'Y-m-d H:i:s'), + /** + * Default timezone. For a list of supported timezones see: + * https://www.php.net/manual/en/timezones.php + * + * Default value: 'UTC' + */ + 'timezone' => Helpers::env('TIMEZONE', 'UTC'), + /** * The maximum file size (in bytes) that can be hashed. This helps to * prevent timeouts for excessively large files. diff --git a/app/src/Factories/TwigFactory.php b/app/src/Factories/TwigFactory.php index b95aa5e..feef4d9 100644 --- a/app/src/Factories/TwigFactory.php +++ b/app/src/Factories/TwigFactory.php @@ -66,6 +66,10 @@ class TwigFactory $this->container->get('date_format'), '%d days' ); + $twig->getEnvironment()->getExtension(CoreExtension::class)->setTimezone( + $this->container->get('timezone') + ); + foreach (self::VIEW_FUNCTIONS as $function) { $function = $this->callableResolver->resolve($function);