eZ\Publish\Core\FieldType\Time\Value::fromTimestamp PHP Method

fromTimestamp() public static method

Creates a Value from the given $timestamp.
public static fromTimestamp ( integer $timestamp ) : static
$timestamp integer
return static
    public static function fromTimestamp($timestamp)
    {
        try {
            $dateTime = new DateTime();
            $dateTime->setTimestamp($timestamp);
            return static::fromDateTime($dateTime);
        } catch (Exception $e) {
            throw new InvalidArgumentValue('$timestamp', $timestamp, __CLASS__, $e);
        }
    }

Usage Example

Example #1
0
 /**
  * Inspects given $inputValue and potentially converts it into a dedicated value object.
  *
  * @param string|int|\DateTime|\eZ\Publish\Core\FieldType\Time\Value $inputValue
  *
  * @return \eZ\Publish\Core\FieldType\Time\Value The potentially converted and structurally plausible value.
  */
 protected function createValueFromInput($inputValue)
 {
     if (is_string($inputValue)) {
         $inputValue = Value::fromString($inputValue);
     }
     if (is_int($inputValue)) {
         $inputValue = Value::fromTimestamp($inputValue);
     }
     if ($inputValue instanceof DateTime) {
         $inputValue = Value::fromDateTime($inputValue);
     }
     return $inputValue;
 }
All Usage Examples Of eZ\Publish\Core\FieldType\Time\Value::fromTimestamp