eZ\Publish\Core\FieldType\Date\Value::fromTimestamp PHP Метод

fromTimestamp() публичный статический Метод

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

Usage Example

Пример #1
0
 /**
  * Get hashes and their respective converted values.
  *
  * This is a PHPUnit data provider
  *
  * The returned records must have the the input hash assigned to the
  * first index and the expected value result to the second. For example:
  *
  * <code>
  * array(
  *      array(
  *          array( 'myValue' => true ),
  *          new MyValue( true ),
  *      ),
  *      // ...
  * );
  * </code>
  *
  * @return array
  */
 public function provideFromHashData()
 {
     $dateTime = new DateTime();
     return array(array(array('timestamp' => $dateTime->setTimestamp(123456)->setTime(0, 0, 0)->getTimestamp(), 'rfc850' => $rfc850 = $dateTime->format(DateTime::RFC850)), DateValue::fromString($rfc850)), array(array('timestamp' => $dateTime->setTimestamp($timestamp = 123456)->setTime(0, 0, 0)->getTimestamp(), 'rfc850' => null), DateValue::fromTimestamp($timestamp)));
 }
All Usage Examples Of eZ\Publish\Core\FieldType\Date\Value::fromTimestamp