当前位置: 首页>>代码示例>>PHP>>正文


PHP DateTime::toTimestamp方法代码示例

本文整理汇总了PHP中Magento\Framework\Stdlib\DateTime::toTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::toTimestamp方法的具体用法?PHP DateTime::toTimestamp怎么用?PHP DateTime::toTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Stdlib\DateTime的用法示例。


在下文中一共展示了DateTime::toTimestamp方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 public function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($date = $object->getDateFrom()) {
         $object->setDateFrom($this->dateTime->formatDate($date));
     } else {
         $object->setDateFrom(null);
     }
     if ($date = $object->getDateTo()) {
         $object->setDateTo($this->dateTime->formatDate($date));
     } else {
         $object->setDateTo(null);
     }
     if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && $this->dateTime->toTimestamp($object->getDateFrom()) > $this->dateTime->toTimestamp($object->getDateTo())) {
         throw new \Magento\Framework\Model\Exception(__('Start date cannot be greater than end date.'));
     }
     $check = $this->_checkIntersection($object->getStoreId(), $object->getDateFrom(), $object->getDateTo(), $object->getId());
     if ($check) {
         throw new \Magento\Framework\Model\Exception(__('Your design change for the specified store intersects with another one, please specify another date range.'));
     }
     if ($object->getDateFrom() === null) {
         $object->setDateFrom(new \Zend_Db_Expr('null'));
     }
     if ($object->getDateTo() === null) {
         $object->setDateTo(new \Zend_Db_Expr('null'));
     }
     parent::_beforeSave($object);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:34,代码来源:Design.php

示例2: setSelectPeriod

 /**
  * Filters the summaries by some period
  *
  * @param string $periodType
  * @param string|int|null $customStart
  * @param string|int|null $customEnd
  * @return $this
  */
 public function setSelectPeriod($periodType, $customStart = null, $customEnd = null)
 {
     switch ($periodType) {
         case "24h":
             $customStart = $this->dateTime->toTimestamp(true) - 86400;
             $customEnd = $this->dateTime->toTimestamp(true);
             break;
         case "7d":
             $customStart = $this->dateTime->toTimestamp(true) - 604800;
             $customEnd = $this->dateTime->toTimestamp(true);
             break;
         case "30d":
             $customStart = $this->dateTime->toTimestamp(true) - 2592000;
             $customEnd = $this->dateTime->toTimestamp(true);
             break;
         case "1y":
             $customStart = $this->dateTime->toTimestamp(true) - 31536000;
             $customEnd = $this->dateTime->toTimestamp(true);
             break;
         default:
             if (is_string($customStart)) {
                 $customStart = strtotime($customStart);
             }
             if (is_string($customEnd)) {
                 $customEnd = strtotime($customEnd);
             }
             break;
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:38,代码来源:AbstractCollection.php

示例3: testGetStoreCreateDate

 /**
  * @magentoDataFixture Magento/Customer/_files/customer.php
  */
 public function testGetStoreCreateDate()
 {
     $customer = $this->_loadCustomer();
     $date = $this->_context->getLocaleDate()->scopeDate($customer->getStoreId(), $this->dateTime->toTimestamp($customer->getCreatedAt()), true);
     $storeCreateDate = $this->_block->formatDate($date, \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true);
     $this->assertEquals($storeCreateDate, $this->_block->getStoreCreateDate());
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:10,代码来源:PersonalInfoTest.php

示例4: getLoginAtTimestamp

 /**
  * Return last login at in Unix time format
  *
  * @return int
  */
 public function getLoginAtTimestamp()
 {
     $loginAt = $this->getLoginAt();
     if ($loginAt) {
         return $this->dateTime->toTimestamp($loginAt);
     }
     return null;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Customer.php

示例5: _updateDiscountPercents

 /**
  * Update tax percents for WEEE based on products condition
  *
  * @param Product|ConditionInterface|int $productCondition
  * @return $this
  */
 protected function _updateDiscountPercents($productCondition = null)
 {
     $now = $this->dateTime->toTimestamp($this->dateTime->now());
     $adapter = $this->_getWriteAdapter();
     $select = $this->_getReadAdapter()->select();
     $select->from(array('data' => $this->getTable('catalogrule_product')));
     $deleteCondition = '';
     if ($productCondition) {
         if ($productCondition instanceof Product) {
             $select->where('product_id = ?', (int) $productCondition->getId());
             $deleteCondition = $adapter->quoteInto('entity_id=?', (int) $productCondition->getId());
         } elseif ($productCondition instanceof ConditionInterface) {
             $productCondition = $productCondition->getIdsSelect($adapter)->__toString();
             $select->where("product_id IN ({$productCondition})");
             $deleteCondition = "entity_id IN ({$productCondition})";
         } else {
             $select->where('product_id = ?', (int) $productCondition);
             $deleteCondition = $adapter->quoteInto('entity_id = ?', (int) $productCondition);
         }
     } else {
         $select->where('(from_time <= ? OR from_time = 0)', $now)->where('(to_time >= ? OR to_time = 0)', $now);
     }
     $adapter->delete($this->getTable('weee_discount'), $deleteCondition);
     $select->order(array('data.website_id', 'data.customer_group_id', 'data.product_id', 'data.sort_order'));
     $data = $this->_getReadAdapter()->query($select);
     $productData = array();
     $stops = array();
     $prevKey = false;
     while ($row = $data->fetch()) {
         $key = "{$row['product_id']}-{$row['website_id']}-{$row['customer_group_id']}";
         if (isset($stops[$key]) && $stops[$key]) {
             continue;
         }
         if ($prevKey && $prevKey != $key) {
             foreach ($productData as $product) {
                 $adapter->insert($this->getTable('weee_discount'), $product);
             }
             $productData = array();
         }
         if ($row['action_operator'] == 'by_percent') {
             if (isset($productData[$key])) {
                 $productData[$key]['value'] -= $productData[$key]['value'] / 100 * $row['action_amount'];
             } else {
                 $productData[$key] = array('entity_id' => $row['product_id'], 'customer_group_id' => $row['customer_group_id'], 'website_id' => $row['website_id'], 'value' => 100 - max(0, min(100, $row['action_amount'])));
             }
         }
         if ($row['action_stop']) {
             $stops[$key] = true;
         }
         $prevKey = $key;
     }
     foreach ($productData as $product) {
         $adapter->insert($this->getTable('weee_discount'), $product);
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:62,代码来源:Tax.php

示例6: registerIds

 /**
  * Add information about product ids to visitor/customer
  *
  * @param \Magento\Framework\Object|\Magento\Reports\Model\Product\Index\AbstractIndex $object
  * @param array $productIds
  * @return $this
  */
 public function registerIds(\Magento\Framework\Object $object, $productIds)
 {
     $row = array('visitor_id' => $object->getVisitorId(), 'customer_id' => $object->getCustomerId(), 'store_id' => $object->getStoreId());
     $addedAt = $this->dateTime->toTimestamp(true);
     $data = array();
     foreach ($productIds as $productId) {
         $productId = (int) $productId;
         if ($productId) {
             $row['product_id'] = $productId;
             $row['added_at'] = $this->dateTime->formatDate($addedAt);
             $data[] = $row;
         }
         $addedAt -= $addedAt > 0 ? 1 : 0;
     }
     $matchFields = array('product_id', 'store_id');
     foreach ($data as $row) {
         $this->_resourceHelper->mergeVisitorProductIndex($this->getMainTable(), $row, $matchFields);
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:27,代码来源:AbstractIndex.php

示例7: isResetPasswordLinkTokenExpired

 /**
  * Check if current reset password link token is expired
  *
  * @return bool
  */
 public function isResetPasswordLinkTokenExpired()
 {
     $linkToken = $this->getRpToken();
     $linkTokenCreatedAt = $this->getRpTokenCreatedAt();
     if (empty($linkToken) || empty($linkTokenCreatedAt)) {
         return true;
     }
     $expirationPeriod = $this->_userData->getResetPasswordLinkExpirationPeriod();
     $currentTimestamp = $this->dateTime->toTimestamp($this->dateTime->now());
     $tokenTimestamp = $this->dateTime->toTimestamp($linkTokenCreatedAt);
     if ($tokenTimestamp > $currentTimestamp) {
         return true;
     }
     $dayDifference = floor(($currentTimestamp - $tokenTimestamp) / (24 * 60 * 60));
     if ($dayDifference >= $expirationPeriod) {
         return true;
     }
     return false;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:24,代码来源:User.php

示例8: getCreatedAtStoreDate

 /**
  * Get object created at date affected with object store timezone
  *
  * @return \Magento\Framework\Stdlib\DateTime\Date
  */
 public function getCreatedAtStoreDate()
 {
     return $this->_localeDate->scopeDate($this->getStore(), $this->dateTime->toTimestamp($this->getCreatedAt()), true);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:9,代码来源:AbstractModel.php

示例9: getStoreCreateDate

 /**
  * @return string
  */
 public function getStoreCreateDate()
 {
     $date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $this->dateTime->toTimestamp($this->getCustomer()->getCreatedAt()), true);
     return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:8,代码来源:View.php


注:本文中的Magento\Framework\Stdlib\DateTime::toTimestamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。