diff --git a/eZ/Publish/Core/FieldType/DateAndTime/Value.php b/eZ/Publish/Core/FieldType/DateAndTime/Value.php index 57b88bd0b9..702f8e9941 100644 --- a/eZ/Publish/Core/FieldType/DateAndTime/Value.php +++ b/eZ/Publish/Core/FieldType/DateAndTime/Value.php @@ -10,7 +10,6 @@ use eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue; use Exception; use DateTime; -use DateTimeZone; /** * Value for DateAndTime field type. @@ -51,7 +50,7 @@ public function __construct(DateTime $dateTime = null) public static function fromString($dateString) { try { - return new static(static::getDateTime($dateString)); + return new static(new DateTime($dateString)); } catch (Exception $e) { throw new InvalidArgumentValue('$dateString', $dateString, __CLASS__, $e); } @@ -67,27 +66,15 @@ public static function fromString($dateString) public static function fromTimestamp($timestamp) { try { - return new static(static::getDateTime("@{$timestamp}")); + $dateTime = new DateTime(); + $dateTime->setTimestamp($timestamp); + + return new static($dateTime); } catch (Exception $e) { throw new InvalidArgumentValue('$timestamp', $timestamp, __CLASS__, $e); } } - /** - * Creates a DateTime object from the string with respecting server timezone. - * - * @param string $datetime - * - * @return \DateTime - */ - public static function getDateTime($datetime) - { - $dt = new DateTime($datetime); - $dt->setTimezone(new DateTimeZone(date_default_timezone_get())); - - return $dt; - } - /** * @see \eZ\Publish\Core\FieldType\Value */