type = self::XMLRPC_TYPE_DATETIME; if ($value instanceof \DateTime) { $this->value = $value->format($this->phpFormatString); } elseif (is_numeric($value)) { // The value is numeric, we make sure it is an integer $this->value = date($this->phpFormatString, (int) $value); } else { try { $dateTime = new \DateTime($value); } catch (\Exception $e) { throw new Exception\ValueException($e->getMessage(), $e->getCode(), $e); } $this->value = $dateTime->format($this->phpFormatString); // Convert the DateTime to iso8601 format } } /** * Return the value of this object as iso8601 dateTime value * * @return int As a Unix timestamp */ public function getValue() { return $this->value; } }