/** * @see Document\Tag\TagInterface::frontend */ public function frontend() { if (!isset($this->options["format"]) || !$this->options["format"]) { $this->options["format"] = \DateTime::ISO8601; } if ($this->date instanceof \Zend_Date) { return $this->date->toString($this->options["format"], "php"); } elseif ($this->date instanceof \DateTimeInterface) { return $this->date->formatLocalized($this->options["format"]); } }
public function toString() { if (is_null($this->value)) { return ""; } else { return parent::toString(); } }
/** * Convert the DateTime into an AMF Date * * @param DateTime|Zend_Date $data * @return Zend_Amf_Parse_Amf0_Serializer */ public function writeDate($data) { if ($data instanceof DateTime) { $dateString = $data->format('U'); } elseif ($data instanceof Zend_Date) { $dateString = $data->toString('U'); } else { // // require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Invalid date specified; must be a DateTime or Zend_Date object'); } $dateString *= 1000; // Make the conversion and remove milliseconds. $this->_stream->writeDouble($dateString); // Flash does not respect timezone but requires it. $this->_stream->writeInt(0); return $this; }
/** * Convert DateTime/Zend_Date to AMF date * * @param DateTime|Zend_Date $date * @return Zend_Amf_Parse_Amf3_Serializer */ public function writeDate($date) { if ($date instanceof DateTime) { $dateString = $date->format('U') * 1000; } elseif ($date instanceof Zend_Date) { $dateString = $date->toString('U') * 1000; } else { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Invalid date specified; must be a string DateTime or Zend_Date object'); } $this->writeInteger(0x1); // write time to stream minus milliseconds $this->_stream->writeDouble($dateString); return $this; }
/** * Returns modification of a given record in a given timespan * * @param string _application application of given identifier * @param string _id identifier to retreave modification log for * @param string _type * @param string _backend * @param Tinebase_DateTime _from beginning point of timespan, excluding point itself * @param Tinebase_DateTime _until end point of timespan, including point itself * @param int _modifierId optional * @return Tinebase_Record_RecordSet RecordSet of Tinebase_Model_ModificationLog */ public function getModifications($_application, $_id, $_type = NULL, $_backend, DateTime $_from, DateTime $_until, $_modifierId = NULL) { $application = Tinebase_Application::getInstance()->getApplicationByName($_application); $isoDef = 'Y-m-d\\TH:i:s'; $db = $this->_table->getAdapter(); $select = $db->select()->from($this->_tablename)->order('modification_time ASC')->where($db->quoteInto($db->quoteIdentifier('application_id') . ' = ?', $application->id))->where($db->quoteInto($db->quoteIdentifier('record_id') . ' = ?', $_id))->where($db->quoteInto($db->quoteIdentifier('modification_time') . ' > ?', $_from->toString($isoDef)))->where($db->quoteInto($db->quoteIdentifier('modification_time') . ' <= ?', $_until->toString($isoDef))); if ($_type) { $select->where($db->quoteInto($db->quoteIdentifier('record_type') . ' LIKE ?', $_type)); } if ($_backend) { $select->where($db->quoteInto($db->quoteIdentifier('record_backend') . ' LIKE ?', $_backend)); } if ($_modifierId) { $select->where($db->quoteInto($db->quoteIdentifier('modification_account') . ' = ?', $_modifierId)); } $stmt = $db->query($select); $resultArray = $stmt->fetchAll(Zend_Db::FETCH_ASSOC); $modifications = new Tinebase_Record_RecordSet('Tinebase_Model_ModificationLog', $resultArray); return $modifications; }
/** * @see Object\ClassDefinition\Data::getVersionPreview * @param \Zend_Date|\DateTime $data * @param null|Object\AbstractObject $object * @param mixed $params * @return string */ public function getVersionPreview($data, $object = null, $params = []) { if ($data instanceof \Zend_Date) { return $data->toString("Y-m-d H:i", "php"); } elseif ($data instanceof \DateTime) { return $data->format("Y-m-d H:i"); } }
public function testMysqlDateTimeFormat() { $date = new DateTime('2015-04-25 19:35:20'); $this->assertEquals('2015-04-25T19:35:20Z', $date->toString()); }