public function testGetGmtOffset() { $this->assertSame(-28800, $this->dateTime->getGmtOffset('seconds')); $this->assertSame(-28800, $this->dateTime->getGmtOffset('seconds11')); $this->assertSame(-480, $this->dateTime->getGmtOffset('minutes')); $this->assertSame(-8, $this->dateTime->getGmtOffset('hours')); }
public function testGetGmtOffset() { if (date('I')) { $this->assertSame(-25200, $this->dateTime->getGmtOffset('seconds')); $this->assertSame(-25200, $this->dateTime->getGmtOffset('seconds11')); $this->assertSame(-420, $this->dateTime->getGmtOffset('minutes')); $this->assertSame(-7, $this->dateTime->getGmtOffset('hours')); } else { $this->assertSame(-28800, $this->dateTime->getGmtOffset('seconds')); $this->assertSame(-28800, $this->dateTime->getGmtOffset('seconds11')); $this->assertSame(-480, $this->dateTime->getGmtOffset('minutes')); $this->assertSame(-8, $this->dateTime->getGmtOffset('hours')); } }
/** * @return $this */ protected function _afterLoadData() { parent::_afterLoadData(); if ($this->_addDaysInWishlist) { $gmtOffset = (int) $this->_date->getGmtOffset(); $nowTimestamp = $this->_date->timestamp(); foreach ($this as $wishlistItem) { $wishlistItemTimestamp = $this->_date->timestamp($wishlistItem->getAddedAt()); $wishlistItem->setDaysInWishlist((int) (($nowTimestamp - $gmtOffset - $wishlistItemTimestamp) / 24 / 60 / 60)); } } return $this; }
/** * @param IFormat $toolFormat * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime */ public function __construct(IFormat $toolFormat, \Magento\Framework\Stdlib\DateTime\DateTime $dateTime) { $this->_toolFormat = $toolFormat; $this->_tzDelta = $dateTime->getGmtOffset(); }
/** * Prepare link to display in grid * * @param \Magento\Framework\DataObject $row * @return string */ public function render(\Magento\Framework\DataObject $row) { $time = date('Y-m-d H:i:s', strtotime($row->getSitemapTime()) + $this->_date->getGmtOffset()); return $time; }
/** * Return offset of current timezone with GMT in seconds * * @return int */ public function getTimezoneOffsetSeconds() { return $this->_date->getGmtOffset(); }