From 84b7bf87a11414fb0eb9d83a33eafb2fd6f67c70 Mon Sep 17 00:00:00 2001 From: Mahdi Ziraki Date: Mon, 21 Feb 2022 00:28:35 +0330 Subject: [PATCH] fix timezone initialization from DateTime or Carbon object --- src/Traits/Creator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Traits/Creator.php b/src/Traits/Creator.php index e1119f1..b4a7068 100644 --- a/src/Traits/Creator.php +++ b/src/Traits/Creator.php @@ -31,7 +31,11 @@ trait Creator } try { - parent::__construct($dt, static::createTimeZone($timezone)); + $tz = static::createTimeZone($timezone); + parent::__construct($dt, $tz); + if ($datetime instanceof DateTime) { + parent::setTimezone($tz); + } self::loadMessages(); } catch (Exception $exception) { throw new InvalidArgumentException(sprintf("Unknown datetime '%s'", $datetime));