當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateTime::gmtDate方法代碼示例

本文整理匯總了PHP中Magento\Framework\Stdlib\DateTime\DateTime::gmtDate方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTime::gmtDate方法的具體用法?PHP DateTime::gmtDate怎麽用?PHP DateTime::gmtDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Stdlib\DateTime\DateTime的用法示例。


在下文中一共展示了DateTime::gmtDate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _beforeSave

 /**
  * Process testimonial data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getId() || !$object->getDate()) {
         $object->setDate($this->_date->gmtDate());
     }
     return parent::_beforeSave($object);
 }
開發者ID:swissup,項目名稱:testimonials,代碼行數:14,代碼來源:Data.php

示例2: testGmtDate

 public function testGmtDate()
 {
     $time = 1403858418;
     $this->localeDate->expects($this->any())->method('date')->with($time)->will($this->returnValue($this->date));
     $this->assertSame(false, $this->dateTime->gmtDate(null, 'tro-lo-lo'));
     $this->assertSame('2014-06-27', $this->dateTime->gmtDate('Y-m-d', $time));
 }
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例3: changeQueueStatusWithLocking

 /**
  * Update the status of a queue record and check to confirm the exclusive change
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return bool
  */
 public function changeQueueStatusWithLocking(AbstractModel $object)
 {
     /* @var $object \ClassyLlama\AvaTax\Model\Queue */
     $object->setUpdatedAt($this->dateTime->gmtDate());
     $data = $this->prepareDataForUpdate($object);
     $originalQueueStatus = $object->getOrigData(self::QUEUE_STATUS_FIELD_NAME);
     $originalUpdatedAt = $object->getOrigData(self::UPDATED_AT_FIELD_NAME);
     // A conditional update does a read lock on update so we use the condition on the old
     // queue status here to guarantee that nothing else has modified the status for processing
     $condition = array();
     // update only the queue record identified by Id
     $condition[] = $this->getConnection()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
     // only update the record if it is still pending
     $condition[] = $this->getConnection()->quoteInto(self::QUEUE_STATUS_FIELD_NAME . '=?', $originalQueueStatus);
     // only update the record if nothing else has updated it
     if ($originalUpdatedAt === null) {
         $condition[] = self::UPDATED_AT_FIELD_NAME . ' IS NULL';
     } else {
         $condition[] = $this->getConnection()->quoteInto(self::UPDATED_AT_FIELD_NAME . '=?', $originalUpdatedAt);
     }
     // update the record and get the number of affected records
     $affectedRowCount = $this->getConnection()->update($this->getMainTable(), $data, $condition);
     $result = false;
     if ($affectedRowCount > 0) {
         $object->setHasDataChanges(false);
         $result = true;
     }
     return $result;
 }
開發者ID:classyllama,項目名稱:ClassyLlama_AvaTax,代碼行數:35,代碼來源:Queue.php

示例4: _beforeSave

 /**
  * Before saving the object, add the created or updated times
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
開發者ID:richdynamix,項目名稱:personalised-products,代碼行數:14,代碼來源:Export.php

示例5: _beforeSave

 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getId()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     $object->setUpdatedAt($this->_date->gmtDate());
     return $this;
 }
開發者ID:pradeeprcs,項目名稱:TestModule,代碼行數:8,代碼來源:Test.php

示例6: _beforeSave

 /**
  * Process post data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->isValidNewsblock($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please fill out newsblock fields.'));
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
開發者ID:Tossimo,項目名稱:Newsblock,代碼行數:15,代碼來源:Newsblock.php

示例7: _beforeSave

 /**
  * Perform operations before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->getIsUniqueBlockToStores($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('A block identifier with the same properties already exists in the selected store.'));
     }
     if (!$object->getId()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return $this;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:18,代碼來源:Block.php

示例8: _beforeSave

 /**
  * Process post data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->isValidPostUrlKey($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The post URL key contains capital letters or disallowed symbols.'));
     }
     if ($this->isNumericPostUrlKey($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The post URL key cannot be made of only numbers.'));
     }
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
開發者ID:luxwan13,項目名稱:magento2-learning,代碼行數:21,代碼來源:Post.php

示例9: _beforeSave

 /**
  * before save callback
  *
  * @param AbstractModel|\Sample\News\Model\Author $object
  * @return $this
  */
 protected function _beforeSave(AbstractModel $object)
 {
     foreach (['dob'] as $field) {
         $value = !$object->getData($field) ? null : $object->getData($field);
         $object->setData($field, $this->dateTime->formatDate($value));
     }
     $object->setUpdatedAt($this->date->gmtDate());
     if ($object->isObjectNew()) {
         $object->setCreatedAt($this->date->gmtDate());
     }
     $urlKey = $object->getData('url_key');
     if ($urlKey == '') {
         $urlKey = $object->getName();
     }
     $urlKey = $object->formatUrlKey($urlKey);
     $object->setUrlKey($urlKey);
     $validKey = false;
     while (!$validKey) {
         if ($this->getIsUniqueAuthorToStores($object)) {
             $validKey = true;
         } else {
             $parts = explode('-', $urlKey);
             $last = $parts[count($parts) - 1];
             if (!is_numeric($last)) {
                 $urlKey = $urlKey . '-1';
             } else {
                 $suffix = '-' . ($last + 1);
                 unset($parts[count($parts) - 1]);
                 $urlKey = implode('-', $parts) . $suffix;
             }
             $object->setData('url_key', $urlKey);
         }
     }
     return parent::_beforeSave($object);
 }
開發者ID:sz-bill,項目名稱:Magento2.x,代碼行數:41,代碼來源:Author.php

示例10: _beforeSave

 /**
  * Process page data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     /*
      * For two attributes which represent timestamp data in DB
      * we should make converting such as:
      * If they are empty we need to convert them into DB
      * type NULL so in DB they will be empty and not some default value
      */
     foreach (array('custom_theme_from', 'custom_theme_to') as $field) {
         $value = !$object->getData($field) ? null : $object->getData($field);
         $object->setData($field, $this->dateTime->formatDate($value));
     }
     if (!$object->getData('identifier')) {
         $object->setData('identifier', $this->filter->translitUrl($object->getData('title')));
     }
     if (!$this->getIsUniquePageToStores($object)) {
         throw new \Magento\Framework\Model\Exception(__('A page URL key for specified store already exists.'));
     }
     if (!$this->isValidPageIdentifier($object)) {
         throw new \Magento\Framework\Model\Exception(__('The page URL key contains capital letters or disallowed symbols.'));
     }
     if ($this->isNumericPageIdentifier($object)) {
         throw new \Magento\Framework\Model\Exception(__('The page URL key cannot be made of only numbers.'));
     }
     // modify create / update dates
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:38,代碼來源:Page.php

示例11: _finishQueue

 /**
  * Finish queue: set status SENT and update finish date
  *
  * @return $this
  */
 protected function _finishQueue()
 {
     $this->setQueueFinishAt($this->_date->gmtDate());
     $this->setQueueStatus(self::STATUS_SENT);
     $this->save();
     return $this;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:12,代碼來源:Queue.php

示例12: _getLoadByIdentifierSelect

 /**
  * Check if post identifier exist for specific store
  * return post id if post exists
  *
  * @param string $identifier
  * @param int $storeId
  * @return int
  */
 protected function _getLoadByIdentifierSelect($identifier, $store, $isActive = null)
 {
     $select = $this->getConnection()->select()->from(['cp' => $this->getMainTable()])->join(['cps' => $this->getTable('magefan_blog_post_store')], 'cp.post_id = cps.post_id', [])->where('cp.identifier = ?', $identifier)->where('cps.store_id IN (?)', $store);
     if (!is_null($isActive)) {
         $select->where('cp.is_active = ?', $isActive)->where('cp.publish_time <= ?', $this->_date->gmtDate());
     }
     return $select;
 }
開發者ID:samitrimal,項目名稱:Blog-Extension-for-Magento-2,代碼行數:16,代碼來源:Post.php

示例13: _beforeSave

 /**
  * @param \Magento\Framework\Model\AbstractModel $object
  *
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->isSlugEmpty($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Something wrong with slug'));
     }
     if (!$this->isSlugValid($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('This post slug contain disallowed symbols.'));
     }
     if ($this->isSlugNumeric($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Post slug can\'t be made of only numbers'));
     }
     if ($object->isObjectNew() && !$object->hasCreatedAt()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     $object->setUpdatedAt($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
開發者ID:pyvil,項目名稱:magento2-blog-module,代碼行數:23,代碼來源:Post.php

示例14: _setFlagData

 /**
  * Saves flag
  *
  * @param string $code
  * @param mixed $value
  * @return $this
  */
 protected function _setFlagData($code, $value = null)
 {
     $this->_getFlag()->setReportFlagCode($code)->unsetData()->loadSelf();
     if ($value !== null) {
         $this->_getFlag()->setFlagData($value);
     }
     // touch last_update
     $this->_getFlag()->setLastUpdate($this->dateTime->gmtDate());
     $this->_getFlag()->save();
     return $this;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:18,代碼來源:AbstractReport.php

示例15: _beforeSave

 /**
  * Process form data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \AddictedToMagento\DynamicForms\Model\Form $object */
     if (!$this->isValidFormIdentifier($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The Form Identifier contains capital letters or disallowed symbols.'));
     }
     if ($object->isObjectNew() && !$object->hasData(FormInterface::CREATION_TIME)) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
開發者ID:AddictedToMagento,項目名稱:dynamic-forms,代碼行數:19,代碼來源:Form.php


注:本文中的Magento\Framework\Stdlib\DateTime\DateTime::gmtDate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。