本文整理汇总了PHP中Magento\Framework\Stdlib\DateTime\TimezoneInterface::getConfigTimezone方法的典型用法代码示例。如果您正苦于以下问题:PHP TimezoneInterface::getConfigTimezone方法的具体用法?PHP TimezoneInterface::getConfigTimezone怎么用?PHP TimezoneInterface::getConfigTimezone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Stdlib\DateTime\TimezoneInterface
的用法示例。
在下文中一共展示了TimezoneInterface::getConfigTimezone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setValue
/**
* Set date value
*
* @param mixed $value
* @return $this
*/
public function setValue($value)
{
if (empty($value)) {
$this->_value = '';
return $this;
}
if ($value instanceof \DateTimeInterface) {
$this->_value = $value;
return $this;
}
if (preg_match('/^[0-9]+$/', $value)) {
$this->_value = (new \DateTime())->setTimestamp($this->_toTimestamp($value));
return $this;
}
try {
$this->_value = new \DateTime($value, new \DateTimeZone($this->localeDate->getConfigTimezone()));
} catch (\Exception $e) {
$this->_value = '';
}
return $this;
}
示例2: __construct
/**
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
*/
public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate)
{
$this->_localeDate = $localeDate;
$this->_offset = $this->calculateOffset($this->_localeDate->getConfigTimezone());
}
示例3: 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()));
}
示例4: areTimesDifferentDays
/**
* Check whether timestamps are from different days
*
* @param $timeA
* @param $timeB
* @param $storeId
* @return bool
*/
protected function areTimesDifferentDays($timeA, $timeB, $storeId)
{
if (!$timeA || !$timeB) {
return true;
}
$timezone = $this->localeDate->getConfigTimezone(null, $storeId);
$dateA = new \DateTime($timeA, new \DateTimeZone($this->localeDate->getDefaultTimezone()));
$dateA->setTimezone(new \DateTimeZone($timezone));
$dateB = new \DateTime($timeB, new \DateTimeZone($this->localeDate->getDefaultTimezone()));
$dateB->setTimezone(new \DateTimeZone($timezone));
return $dateA->format('Y-m-d') != $dateB->format('Y-m-d');
}