public static function fromTimestamp($timestamp) { try { return new static(new DateTime("@{$timestamp}")); } catch (Exception $e) { throw new InvalidArgumentValue('$timestamp', $timestamp, __CLASS__, $e); } }
/** * Converts an $hash to the Value defined by the field type * * @param mixed $hash Null or associative array containing timestamp and optionally date in RFC850 format. * * @return \eZ\Publish\Core\FieldType\DateAndTime\Value $value */ public function fromHash($hash) { if ($hash === null) { return $this->getEmptyValue(); } if (isset($hash['rfc850']) && $hash['rfc850']) { return Value::fromString($hash['rfc850']); } return Value::fromTimestamp((int) $hash['timestamp']); }