Skip to content

Commit

Permalink
Merge pull request #302 from leepeuker/use-env-var-for-timezone
Browse files Browse the repository at this point in the history
Use timezone set via env variable
  • Loading branch information
leepeuker authored Apr 8, 2023
2 parents a57795e + 03b7020 commit 6340fed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@
],
);

return $builder->build();
$container = $builder->build();

$timezone = $container->get(\Movary\ValueObject\Config::class)->getAsString('TIMEZONE', \Movary\ValueObject\DateTime::DEFAULT_TIME_ZONE);
date_default_timezone_set($timezone);

return $container;
4 changes: 2 additions & 2 deletions src/ValueObject/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

class DateTime implements JsonSerializable
{
private const DEFAULT_STRING_FORMAT = 'Y-m-d H:i:s';
public const DEFAULT_TIME_ZONE = 'UTC';

private const DEFAULT_TIME_ZONE = 'UTC';
private const DEFAULT_STRING_FORMAT = 'Y-m-d H:i:s';

private const STATE_FORMAT = 'Y-m-d H:i:s.u';

Expand Down

0 comments on commit 6340fed

Please sign in to comment.