public function setValue($value = null, $fromDb = false) { if ($this->isNull($value)) { $value = new ArrayObject(); } if ($fromDb && $value instanceof BSONArray) { $value = $this->convertToArray($value->getArrayCopy()); } parent::setValue($value, $fromDb); $this->value = $this->arr($this->value); return $this; }
public function setValue($value = null, $fromDb = false) { if ($value === null) { return parent::setValue($value, $fromDb); } if ($value instanceof UTCDatetime) { $value = $value->toDateTime()->format(DATE_ISO8601); } elseif ($value instanceof DateTimeObject) { $value = $value->format(DATE_ISO8601); } elseif ($value == 'now') { $value = $this->datetime()->format(DATE_ISO8601); } else { $value = $this->datetime($value)->setTimezone('UTC')->format(DATE_ISO8601); } return parent::setValue($value, $fromDb); }