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

Creates a Value from the given $dateString.
public static fromString ( string $dateString ) : Value
$dateString string
Результат Value
Пример #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)));
 }
Пример #2
0
 /**
  * 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\Date\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"]);
 }