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


PHP TimezoneInterface::formatDateTime方法代码示例

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


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

示例1: getValue

 /**
  * Retrieve attribute value
  *
  * @param \Magento\Framework\DataObject $object
  * @return mixed
  */
 public function getValue(\Magento\Framework\DataObject $object)
 {
     $data = '';
     $value = parent::getValue($object);
     if ($value) {
         $data = $this->_localeDate->formatDateTime(new \DateTime($value), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE);
     }
     return $data;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Datetime.php

示例2: getValue

 /**
  * Get date value as string.
  * Format can be specified, or it will be taken from $this->getFormat()
  *
  * @param string $format (compatible with \DateTime)
  * @return string
  */
 public function getValue($format = null)
 {
     if (empty($this->_value)) {
         return '';
     }
     if (null === $format) {
         $format = $this->getDateFormat();
         $format .= $format && $this->getTimeFormat() ? ' ' : '';
         $format .= $this->getTimeFormat() ? $this->getTimeFormat() : '';
     }
     return $this->localeDate->formatDateTime($this->_value, null, null, null, $this->_value->getTimezone(), $format);
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:19,代码来源:Date.php

示例3: getFormattedOptionValue

 /**
  * Return formatted option value for quote option
  *
  * @param string $optionValue Prepared for cart option value
  * @return string
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function getFormattedOptionValue($optionValue)
 {
     if ($this->_formattedOptionValue === null) {
         if ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE) {
             $result = $this->_localeDate->formatDateTime(new \DateTime($optionValue), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE);
         } elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME) {
             $result = $this->_localeDate->formatDateTime(new \DateTime($optionValue), \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
         } elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME) {
             $result = $this->_localeDate->formatDateTime(new \DateTime($optionValue), \IntlDateFormatter::NONE, \IntlDateFormatter::SHORT);
         } else {
             $result = $optionValue;
         }
         $this->_formattedOptionValue = $result;
     }
     return $this->_formattedOptionValue;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:23,代码来源:Date.php

示例4: sendPaymentFailedEmail

 /**
  * Send email id payment was failed
  *
  * @param \Magento\Quote\Model\Quote $checkout
  * @param string $message
  * @param string $checkoutType
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
 {
     $this->inlineTranslation->suspend();
     $template = $this->scopeConfig->getValue('checkout/payment_failed/template', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId());
     $copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId());
     $copyMethod = $this->scopeConfig->getValue('checkout/payment_failed/copy_method', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId());
     $bcc = [];
     if ($copyTo && $copyMethod == 'bcc') {
         $bcc = $copyTo;
     }
     $_receiver = $this->scopeConfig->getValue('checkout/payment_failed/receiver', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId());
     $sendTo = [['email' => $this->scopeConfig->getValue('trans_email/ident_' . $_receiver . '/email', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId()), 'name' => $this->scopeConfig->getValue('trans_email/ident_' . $_receiver . '/name', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId())]];
     if ($copyTo && $copyMethod == 'copy') {
         foreach ($copyTo as $email) {
             $sendTo[] = ['email' => $email, 'name' => null];
         }
     }
     $shippingMethod = '';
     if ($shippingInfo = $checkout->getShippingAddress()->getShippingMethod()) {
         $data = explode('_', $shippingInfo);
         $shippingMethod = $data[0];
     }
     $paymentMethod = '';
     if ($paymentInfo = $checkout->getPayment()) {
         $paymentMethod = $paymentInfo->getMethod();
     }
     $items = '';
     foreach ($checkout->getAllVisibleItems() as $_item) {
         /* @var $_item \Magento\Quote\Model\Quote\Item */
         $items .= $_item->getProduct()->getName() . '  x ' . $_item->getQty() . '  ' . $checkout->getStoreCurrencyCode() . ' ' . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
     }
     $total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal();
     foreach ($sendTo as $recipient) {
         $transport = $this->_transportBuilder->setTemplateIdentifier($template)->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $checkout->getStoreId()])->setTemplateVars(['reason' => $message, 'checkoutType' => $checkoutType, 'dateAndTime' => $this->_localeDate->formatDateTime(new \DateTime(), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::MEDIUM), 'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(), 'customerEmail' => $checkout->getCustomerEmail(), 'billingAddress' => $checkout->getBillingAddress(), 'shippingAddress' => $checkout->getShippingAddress(), 'shippingMethod' => $this->scopeConfig->getValue('carriers/' . $shippingMethod . '/title', \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'paymentMethod' => $this->scopeConfig->getValue('payment/' . $paymentMethod . '/title', \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'items' => nl2br($items), 'total' => $total])->setFrom($this->scopeConfig->getValue('checkout/payment_failed/identity', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId()))->addTo($recipient['email'], $recipient['name'])->addBcc($bcc)->getTransport();
         $transport->sendMessage();
     }
     $this->inlineTranslation->resume();
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:49,代码来源:Data.php

示例5: getStoreDate

 /**
  * Retrieve Date value for store
  *
  * @param int $storeId
  * @param string $date
  * @return string|null
  */
 protected function getStoreDate($storeId, $date = null)
 {
     if (!isset($this->dates[$storeId])) {
         $timezone = $this->scopeConfig->getValue($this->localeDate->getDefaultTimezonePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
         $this->localeResolver->emulate($storeId);
         $dateObj = new \DateTime();
         $dateObj->setTimezone(new \DateTimeZone($timezone));
         $this->dates[$storeId] = $dateObj;
         $this->localeResolver->revert();
     }
     if (!$this->dateTime->isEmptyDate($date)) {
         /** @var \DateTime $dateObj */
         $dateObj = $this->dates[$storeId];
         return $this->localeDate->formatDateTime($dateObj, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE);
     }
     return null;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:24,代码来源:Full.php

示例6: formatTime

 /**
  * Retrieve formatting time
  *
  * @param   \DateTime|string|null $time
  * @param   int $format
  * @param   bool $showDate
  * @return  string
  */
 public function formatTime($time = null, $format = \IntlDateFormatter::SHORT, $showDate = false)
 {
     $time = $time instanceof \DateTimeInterface ? $time : new \DateTime($time);
     return $this->_localeDate->formatDateTime($time, $showDate ? $format : \IntlDateFormatter::NONE, $format);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:AbstractBlock.php

示例7: _getDayInterval

 /**
  * Get interval for a day
  *
  * @param \DateTime $dateStart
  * @return array
  */
 protected function _getDayInterval(\DateTime $dateStart)
 {
     $interval = ['period' => $this->_localeDate->formatDateTime($dateStart, \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE), 'start' => $dateStart->format('Y-m-d 00:00:00'), 'end' => $dateStart->format('Y-m-d 23:59:59')];
     return $interval;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:Collection.php

示例8: formatSyncDate

 /**
  * Format a UTC timestamp (seconds since epoch) to structure expected by frontend
  *
  * @param string $syncDate seconds since epoch
  * @return array
  */
 private function formatSyncDate($syncDate)
 {
     return ['date' => $this->timezone->formatDateTime(new \DateTime('@' . $syncDate), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE), 'time' => $this->timezone->formatDateTime(new \DateTime('@' . $syncDate), \IntlDateFormatter::NONE, \IntlDateFormatter::MEDIUM)];
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:10,代码来源:ComponentGrid.php

示例9: getCreatedAtFormatted

 /**
  * Get formatted order created date in store timezone
  *
  * @param   string $format date format type (short|medium|long|full)
  * @return  string
  */
 public function getCreatedAtFormatted($format)
 {
     return $this->timezone->formatDateTime(new \DateTime($this->getCreatedAt()), $format, $format, null, $this->timezone->getConfigTimezone('store', $this->getStore()));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:Order.php


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