本文整理汇总了PHP中Magento\Framework\Stdlib\DateTime\TimezoneInterface::date方法的典型用法代码示例。如果您正苦于以下问题:PHP TimezoneInterface::date方法的具体用法?PHP TimezoneInterface::date怎么用?PHP TimezoneInterface::date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Stdlib\DateTime\TimezoneInterface
的用法示例。
在下文中一共展示了TimezoneInterface::date方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processCalendarDetails
public function processCalendarDetails($carrierRate, $carrierGroupDetail)
{
$calendarDetails = parent::processCalendarDetails($carrierRate, $carrierGroupDetail);
//transform for current locale
$calendarDetails['start'] = $this->localeDate->date($calendarDetails['start'], null, true)->getTimestamp();
return $calendarDetails;
}
示例2: execute
/**
* Refresh sales order report statistics for last day
*
* @return void
*/
public function execute()
{
$this->localeResolver->emulate(0);
$currentDate = $this->localeDate->date();
$date = $currentDate->sub(new \DateInterval('PT25H'));
$this->orderFactory->create()->aggregate($date);
$this->localeResolver->revert();
}
示例3: execute
/**
* Refresh sales refunded report statistics for last day
*
* @return void
*/
public function execute()
{
$this->localeResolver->emulate(0);
$currentDate = $this->localeDate->date();
$date = $currentDate->subHour(25);
$this->refundedFactory->create()->aggregate($date);
$this->localeResolver->revert();
}
示例4: execute
/**
* Refresh sales coupons report statistics for last day
*
* @return $this
*/
public function execute()
{
$this->_localeResolver->emulate(0);
$currentDate = $this->_localeDate->date();
$date = $currentDate->modify('-25 hours');
$this->_reportRule->aggregate($date);
$this->_localeResolver->revert();
return $this;
}
示例5: invoke
/**
* Refresh sales tax report statistics for last day
*
* @return $this
*/
public function invoke()
{
$this->localeResolver->emulate(0);
$currentDate = $this->localeDate->date();
$date = $currentDate->modify('-25 hours');
/** @var $reportTax \Magento\Tax\Model\ResourceModel\Report\Tax */
$reportTax = $this->reportTaxFactory->create();
$reportTax->aggregate($date);
$this->localeResolver->revert();
return $this;
}
示例6: cleanup
/**
* Delete completed records older then 30 days from provided table.
*
* @param $tableName
*
* @return \Exception|int
*/
public function cleanup($tableName)
{
try {
$interval = new \DateInterval('P30D');
$date = $this->localeDate->date()->sub($interval)->format('Y-m-d H:i:s');
$conn = $this->getConnection();
$num = $conn->delete($tableName, ['created_at < ?' => $date]);
return $num;
} catch (\Exception $e) {
return $e->getMessage();
}
}
示例7: getProductsCollection
/**
* @param int $storeId
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
*/
public function getProductsCollection($storeId)
{
/** @var $product \Magento\Catalog\Model\Product */
$product = $this->productFactory->create();
$todayStartOfDayDate = $this->localeDate->date()->setTime(0, 0)->format('Y-m-d H:i:s');
$todayEndOfDayDate = $this->localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s');
/** @var $products \Magento\Catalog\Model\ResourceModel\Product\Collection */
$products = $product->getResourceCollection();
$products->setStoreId($storeId);
$products->addStoreFilter()->addAttributeToFilter('news_from_date', ['or' => [0 => ['date' => true, 'to' => $todayEndOfDayDate], 1 => ['is' => new \Zend_Db_Expr('null')]]], 'left')->addAttributeToFilter('news_to_date', ['or' => [0 => ['date' => true, 'from' => $todayStartOfDayDate], 1 => ['is' => new \Zend_Db_Expr('null')]]], 'left')->addAttributeToFilter([['attribute' => 'news_from_date', 'is' => new \Zend_Db_Expr('not null')], ['attribute' => 'news_to_date', 'is' => new \Zend_Db_Expr('not null')]])->addAttributeToSort('news_from_date', 'desc')->addAttributeToSelect(['name', 'short_description', 'description'], 'inner')->addAttributeToSelect(['price', 'special_price', 'special_from_date', 'special_to_date', 'msrp_display_actual_price_type', 'msrp', 'thumbnail'], 'left')->applyFrontendPriceLimitations();
$products->setVisibility($this->visibility->getVisibleInCatalogIds());
return $products;
}
示例8: prepareDataSource
/**
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item[$this->getData('name')])) {
$date = $this->timezone->date(new \DateTime($item[$this->getData('name')]));
$item[$this->getData('name')] = $date->format('Y-m-d H:i:s');
}
}
}
return $dataSource;
}
示例9: getValue
/**
* Retrieve attribute value
*
* @param \Magento\Framework\Object $object
* @return mixed
*/
public function getValue(\Magento\Framework\Object $object)
{
$data = '';
$value = parent::getValue($object);
$format = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM);
if ($value) {
try {
$data = $this->_localeDate->date($value, \Zend_Date::ISO_8601, null, false)->toString($format);
} catch (\Exception $e) {
$data = $this->_localeDate->date($value, null, null, false)->toString($format);
}
}
return $data;
}
示例10: _convertFlatToRecursive
/**
* Set specified data to current rule.
* Set conditions and actions recursively.
* Convert dates into \Zend_Date.
*
* @param array $data
* @return array
*/
protected function _convertFlatToRecursive(array $data)
{
$arr = array();
foreach ($data as $key => $value) {
if (($key === 'conditions' || $key === 'actions') && is_array($value)) {
foreach ($value as $id => $data) {
$path = explode('--', $id);
$node =& $arr;
for ($i = 0, $l = sizeof($path); $i < $l; $i++) {
if (!isset($node[$key][$path[$i]])) {
$node[$key][$path[$i]] = array();
}
$node =& $node[$key][$path[$i]];
}
foreach ($data as $k => $v) {
$node[$k] = $v;
}
}
} else {
/**
* Convert dates into \Zend_Date
*/
if (in_array($key, array('from_date', 'to_date')) && $value) {
$value = $this->_localeDate->date($value, \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT, null, false);
}
$this->setData($key, $value);
}
}
return $arr;
}
示例11: _validateExpDate
/**
* @param string $expYear
* @param string $expMonth
* @return bool
*/
protected function _validateExpDate($expYear, $expMonth)
{
$date = $this->_localeDate->date();
if (!$expYear || !$expMonth || $date->compareYear($expYear) == 1 || $date->compareYear($expYear) == 0 && $date->compareMonth($expMonth) == 1) {
return false;
}
return true;
}
示例12: aggregateSalesReportCouponsData
/**
* Refresh sales coupons report statistics for last day
*
* @return $this
*/
public function aggregateSalesReportCouponsData()
{
$this->_localeResolver->emulate(0);
$currentDate = $this->_localeDate->date();
$date = $currentDate->subHour(25);
$this->_reportRule->aggregate($date);
$this->_localeResolver->revert();
return $this;
}
示例13: aggregateSalesReportBestsellersData
/**
* Refresh bestsellers report statistics for last day
*
* @param \Magento\Cron\Model\Schedule $schedule
* @return $this
*/
public function aggregateSalesReportBestsellersData($schedule)
{
$this->_localeResolver->emulate(0);
$currentDate = $this->_localeDate->date();
$date = $currentDate->subHour(25);
$this->_bestsellersFactory->create()->aggregate($date);
$this->_localeResolver->revert();
return $this;
}
示例14: getValue
/**
* @return array
*/
public function getValue()
{
if ($this->getInputType() == 'date' && !$this->getIsValueParsed()) {
// date format intentionally hard-coded
$this->setValue($this->_localeDate->date($this->getData('value'), \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT, null, false)->toString(\Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT));
$this->setIsValueParsed(true);
}
return $this->getData('value');
}
示例15: aggregateSalesReportTaxData
/**
* Refresh sales tax report statistics for last day
*
* @param \Magento\Cron\Model\Schedule $schedule
* @return $this
*/
public function aggregateSalesReportTaxData($schedule)
{
$this->_localeResolver->emulate(0);
$currentDate = $this->_localeDate->date();
$date = $currentDate->subHour(25);
/** @var $reportTax \Magento\Tax\Model\Resource\Report\Tax */
$reportTax = $this->_reportTaxFactory->create();
$reportTax->aggregate($date);
$this->_localeResolver->revert();
return $this;
}