Skip to content

Commit

Permalink
DateTime::format(): Passing null to parameter #1 ($format) of type st…
Browse files Browse the repository at this point in the history
…ring is deprecated
  • Loading branch information
escopecz committed Jun 9, 2023
1 parent c7e9fd8 commit ec3b162
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/bundles/CoreBundle/Helper/DateTimeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public function setDateTime($datetime = '', $fromFormat = self::FORMAT_DB, $time
if ($datetime instanceof \DateTimeInterface) {
$this->datetime = $datetime;
$this->timezone = $datetime->getTimezone()->getName();
$this->string = $this->datetime->format($fromFormat);
$this->string = $fromFormat ? $this->datetime->format($fromFormat) : $datetime;
} elseif (empty($datetime)) {
$this->datetime = new \DateTime('now', new \DateTimeZone($this->timezone));
$this->string = $this->datetime->format($fromFormat);
} elseif (null == $fromFormat) {
$this->string = $fromFormat ? $this->datetime->format($fromFormat) : $datetime;
} elseif (null === $fromFormat) {
$this->string = $datetime;
$this->datetime = new \DateTime($datetime, new \DateTimeZone($this->timezone));
} else {
Expand Down

0 comments on commit ec3b162

Please sign in to comment.