Skip to content

Commit

Permalink
Merge pull request #777 from doctrine/fix-timezone
Browse files Browse the repository at this point in the history
Use UTC timezone consistently when creating dates.
  • Loading branch information
jwage authored Jan 3, 2019
2 parents 8bb3422 + e99ee77 commit 0101f5b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Doctrine/Migrations/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function __construct(
$this->migrationFinder = $migrationFinder;
$this->queryWriter = $queryWriter;
$this->dependencyFactory = $dependencyFactory;
$this->migrationsColumnLength = strlen((new DateTimeImmutable())->format(self::VERSION_FORMAT));
$this->migrationsColumnLength = strlen($this->createDateTime()->format(self::VERSION_FORMAT));
}

public function setName(string $name) : void
Expand Down Expand Up @@ -331,7 +331,7 @@ public function getDateTime(string $version) : string

public function generateVersionNumber(?DateTimeInterface $now = null) : string
{
$now = $now ?: new DateTimeImmutable('now', new DateTimeZone('UTC'));
$now = $now ?: $this->createDateTime();

return $now->format(self::VERSION_FORMAT);
}
Expand Down Expand Up @@ -527,4 +527,9 @@ private function ensureOrganizeMigrationsIsCompatibleWithFinder() : void
);
}
}

private function createDateTime() : DateTimeImmutable
{
return new DateTimeImmutable('now', new DateTimeZone('UTC'));
}
}

0 comments on commit 0101f5b

Please sign in to comment.