Skip to content

Commit

Permalink
Ensure the application uses the UTC timezone all over
Browse files Browse the repository at this point in the history
We do not have the same access to PHP.ini through all development and
production environments. Consequently we set this in the application
kernel instead.
  • Loading branch information
kasperg committed Mar 5, 2024
1 parent 99292be commit 21f4a3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions importers/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
locale: 'en'
timezone: 'UTC'

services:
# default configuration for services in *this* file
Expand Down
10 changes: 10 additions & 0 deletions importers/src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@
class Kernel extends BaseKernel
{
use MicroKernelTrait;

public function boot()
{
parent::boot();
$timezone = $this->getContainer()->getParameter('timezone');
if (!is_string($timezone)) {
throw new \InvalidArgumentException("Timezone parameter is not a string");
}
date_default_timezone_set($timezone);
}
}

0 comments on commit 21f4a3c

Please sign in to comment.