format('Y-m-d H:i:s'), $dt->getTimezone()); } /** * Create DateTimeZone object from string. */ private static function createTimeZone(string $tz): DateTimeZone { try { return new DateTimeZone($tz); } catch (Exception $e) { throw new UnexpectedValueException('Invalid timezone.', 0, $e); } } }