本文整理汇总了PHP中Magento\Framework\Stdlib\DateTime\TimezoneInterface::formatDate方法的典型用法代码示例。如果您正苦于以下问题:PHP TimezoneInterface::formatDate方法的具体用法?PHP TimezoneInterface::formatDate怎么用?PHP TimezoneInterface::formatDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Stdlib\DateTime\TimezoneInterface
的用法示例。
在下文中一共展示了TimezoneInterface::formatDate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$startDate = $this->getHelper('M2ePro')->getCurrentGmtDate();
$synchConfig = $this->modelFactory->getObject('Config\\Manager\\Synchronization');
$synchConfig->setGroupValue('/ebay/templates/revise/total/', 'start_date', $startDate);
$synchConfig->setGroupValue('/ebay/templates/revise/total/', 'last_listing_product_id', 0);
$this->setAjaxContent(json_encode(array('start_date' => $this->localeDate->formatDate($startDate, \IntlDateFormatter::MEDIUM))), false);
}
示例2: _getEstimatedDate
/**
* @param $dataTime
*
* @return string
*/
protected function _getEstimatedDate($dataTime)
{
$current = new \Zend_Date();
$current->setTime(0);
$nextNotificationDate = $current->add($dataTime['shipping'], \Zend_Date::HOUR);
return $this->_timezone->formatDate('@' . $nextNotificationDate->getTimestamp());
}
示例3: getEntries
/**
* Get RSS feed items
*
* @return array
*/
protected function getEntries()
{
/** @var $resourceModel \Magento\Sales\Model\Resource\Order\Rss\OrderStatus */
$resourceModel = $this->orderResourceFactory->create();
$results = $resourceModel->getAllCommentCollection($this->order->getId());
$entries = [];
if ($results) {
foreach ($results as $result) {
$urlAppend = 'view';
$type = $result['entity_type_code'];
if ($type && $type != 'order') {
$urlAppend = $type;
}
$type = __(ucwords($type));
$title = __('Details for %1 #%2', $type, $result['increment_id']);
$description = '<p>' . __('Notified Date: %1', $this->localeDate->formatDate($result['created_at'])) . '<br/>' . __('Comment: %1<br/>', $result['comment']) . '</p>';
$url = $this->urlBuilder->getUrl('sales/order/' . $urlAppend, ['order_id' => $this->order->getId()]);
$entries[] = ['title' => $title, 'link' => $url, 'description' => $description];
}
}
$title = __('Order #%1 created at %2', $this->order->getIncrementId(), $this->localeDate->formatDate($this->order->getCreatedAt()));
$url = $this->urlBuilder->getUrl('sales/order/view', ['order_id' => $this->order->getId()]);
$description = '<p>' . __('Current Status: %1<br/>', $this->order->getStatusLabel()) . __('Total: %1<br/>', $this->order->formatPrice($this->order->getGrandTotal())) . '</p>';
$entries[] = ['title' => $title, 'link' => $url, 'description' => $description];
return ['entries' => $entries];
}
示例4: _showLastExecutionTime
/**
* Add refresh statistics links
*
* @param string $flagCode
* @param string $refreshCode
* @return $this
*/
protected function _showLastExecutionTime($flagCode, $refreshCode)
{
$flag = $this->_objectManager->create('Magento\\Reports\\Model\\Flag')->setReportFlagCode($flagCode)->loadSelf();
$updatedAt = 'undefined';
if ($flag->hasData()) {
$updatedAt = $this->timezone->formatDate($flag->getLastUpdate(), \IntlDateFormatter::MEDIUM, true);
}
$refreshStatsLink = $this->getUrl('reports/report_statistics');
$directRefreshLink = $this->getUrl('reports/report_statistics/refreshRecent', ['code' => $refreshCode]);
$this->messageManager->addNotice(__('Last updated: %1. To refresh last day\'s <a href="%2">statistics</a>, ' . 'click <a href="%3">here</a>.', $updatedAt, $refreshStatsLink, $directRefreshLink));
return $this;
}
示例5: execute
/**
* @param \Magento\Framework\Event\Observer $observer
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$observerData = $observer->getData();
$orderId = $observerData['orderId'];
$shipmentData = $observerData['shipmentData'];
$order = $this->coreModel->_getOrder($orderId);
$method = $order->getShippingMethod();
if ($this->shipmentHelper->isMercadoEnviosMethod($method)) {
$methodId = $shipmentData['shipping_option']['shipping_method_id'];
$name = $shipmentData['shipping_option']['name'];
$order->setShippingMethod('mercadoenvios_' . $methodId);
$estimatedDate = $this->_timezone->formatDate($shipmentData['shipping_option']['estimated_delivery']['date']);
$estimatedDate = __('(estimated date %1)', $estimatedDate);
$shippingDescription = 'MercadoEnvíos - ' . $name . ' ' . $estimatedDate;
$order->setShippingDescription($shippingDescription);
try {
$order->save();
$this->shipmentHelper->log('Order ' . $order->getIncrementId() . ' shipping data set ', $shipmentData);
} catch (\Exception $e) {
$this->shipmentHelper->log("error when update shipment data: " . $e);
$this->shipmentHelper->log($e);
}
}
}
示例6: getRssData
/**
* Get RSS feed items
*
* @return array
*/
public function getRssData()
{
$passDate = $this->dateTime->formatDate(mktime(0, 0, 0, date('m'), date('d') - 7));
$newUrl = $this->rssUrlBuilder->getUrl(['_secure' => true, '_nosecret' => true, 'type' => 'new_order']);
$title = __('New Orders');
$data = ['title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8'];
/** @var $order \Magento\Sales\Model\Order */
$order = $this->orderFactory->create();
/** @var $collection \Magento\Sales\Model\ResourceModel\Order\Collection */
$collection = $order->getResourceCollection();
$collection->addAttributeToFilter('created_at', ['date' => true, 'from' => $passDate])->addAttributeToSort('created_at', 'desc');
$this->eventManager->dispatch('rss_order_new_collection_select', ['collection' => $collection]);
$detailBlock = $this->layout->getBlockSingleton('Magento\\Sales\\Block\\Adminhtml\\Order\\Details');
foreach ($collection as $item) {
$title = __('Order #%1 created at %2', $item->getIncrementId(), $this->localeDate->formatDate($item->getCreatedAt()));
$url = $this->urlBuilder->getUrl('sales/order/view', ['_secure' => true, 'order_id' => $item->getId(), '_nosecret' => true]);
$detailBlock->setOrder($item);
$data['entries'][] = ['title' => $title, 'link' => $url, 'description' => $detailBlock->toHtml()];
}
return $data;
}
示例7: getCreatedAtFormated
/**
* Get formated order created date in store timezone
*
* @param string $format date format type (short|medium|long|full)
* @return string
*/
public function getCreatedAtFormated($format)
{
return $this->timezone->formatDate($this->timezone->scopeDate($this->getStore(), $this->getCreatedAt(), true), $format, true);
}
示例8: insertOrder
/**
* Insert order to pdf page
*
* @param \Zend_Pdf_Page &$page
* @param \Magento\Sales\Model\Order $obj
* @param bool $putOrderId
* @return void
*/
protected function insertOrder(&$page, $obj, $putOrderId = true)
{
if ($obj instanceof \Magento\Sales\Model\Order) {
$shipment = null;
$order = $obj;
} elseif ($obj instanceof \Magento\Sales\Model\Order\Shipment) {
$shipment = $obj;
$order = $shipment->getOrder();
}
$this->y = $this->y ? $this->y : 815;
$top = $this->y;
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(0.45));
$page->setLineColor(new \Zend_Pdf_Color_GrayScale(0.45));
$page->drawRectangle(25, $top, 570, $top - 55);
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
$this->setDocHeaderCoordinates(array(25, $top, 570, $top - 55));
$this->_setFontRegular($page, 10);
if ($putOrderId) {
$page->drawText(__('Order # ') . $order->getRealOrderId(), 35, $top -= 30, 'UTF-8');
}
$page->drawText(__('Order Date: ') . $this->_localeDate->formatDate($order->getCreatedAtStoreDate(), 'medium', false), 35, $top -= 15, 'UTF-8');
$top -= 10;
$page->setFillColor(new \Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
$page->setLineColor(new \Zend_Pdf_Color_GrayScale(0.5));
$page->setLineWidth(0.5);
$page->drawRectangle(25, $top, 275, $top - 25);
$page->drawRectangle(275, $top, 570, $top - 25);
/* Calculate blocks info */
/* Billing Address */
$billingAddress = $this->_formatAddress($order->getBillingAddress()->format('pdf'));
/* Payment */
$paymentInfo = $this->_paymentData->getInfoBlock($order->getPayment())->setIsSecureMode(true)->toPdf();
$paymentInfo = htmlspecialchars_decode($paymentInfo, ENT_QUOTES);
$payment = explode('{{pdf_row_separator}}', $paymentInfo);
foreach ($payment as $key => $value) {
if (strip_tags(trim($value)) == '') {
unset($payment[$key]);
}
}
reset($payment);
/* Shipping Address and Method */
if (!$order->getIsVirtual()) {
/* Shipping Address */
$shippingAddress = $this->_formatAddress($order->getShippingAddress()->format('pdf'));
$shippingMethod = $order->getShippingDescription();
}
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
$this->_setFontBold($page, 12);
$page->drawText(__('Sold to:'), 35, $top - 15, 'UTF-8');
if (!$order->getIsVirtual()) {
$page->drawText(__('Ship to:'), 285, $top - 15, 'UTF-8');
} else {
$page->drawText(__('Payment Method:'), 285, $top - 15, 'UTF-8');
}
$addressesHeight = $this->_calcAddressHeight($billingAddress);
if (isset($shippingAddress)) {
$addressesHeight = max($addressesHeight, $this->_calcAddressHeight($shippingAddress));
}
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
$page->drawRectangle(25, $top - 25, 570, $top - 33 - $addressesHeight);
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
$this->_setFontRegular($page, 10);
$this->y = $top - 40;
$addressesStartY = $this->y;
foreach ($billingAddress as $value) {
if ($value !== '') {
$text = array();
foreach ($this->string->split($value, 45, true, true) as $_value) {
$text[] = $_value;
}
foreach ($text as $part) {
$page->drawText(strip_tags(ltrim($part)), 35, $this->y, 'UTF-8');
$this->y -= 15;
}
}
}
$addressesEndY = $this->y;
if (!$order->getIsVirtual()) {
$this->y = $addressesStartY;
foreach ($shippingAddress as $value) {
if ($value !== '') {
$text = array();
foreach ($this->string->split($value, 45, true, true) as $_value) {
$text[] = $_value;
}
foreach ($text as $part) {
$page->drawText(strip_tags(ltrim($part)), 285, $this->y, 'UTF-8');
$this->y -= 15;
}
}
}
$addressesEndY = min($addressesEndY, $this->y);
//.........这里部分代码省略.........
示例9: formatDate
/**
* Retrieve formatting date
*
* @param \Zend_Date|string|null $date
* @param string $format
* @param bool $showTime
* @return string
*/
public function formatDate($date = null, $format = \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, $showTime = false)
{
return $this->_localeDate->formatDate($date, $format, $showTime);
}