/** * Convert given date to default (UTC) timezone * * @param string $date * @return \DateTime|null */ protected function _convertDate($date) { if ($this->getColumn()->getFilterTime()) { try { $adminTimeZone = new \DateTimeZone($this->_scopeConfig->getValue($this->_localeDate->getDefaultTimezonePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); $simpleRes = new \DateTime($date, $adminTimeZone); $simpleRes->setTimezone(new \DateTimeZone('UTC')); return $simpleRes; } catch (\Exception $e) { return null; } } return parent::_convertDate($date); }
/** * Convert given date to default (UTC) timezone * * @param string $date * @return \DateTime|null */ protected function _convertDate($date) { if ($this->getColumn()->getFilterTime()) { try { $timezone = $this->getColumn()->getTimezone() !== false ? $this->_localeDate->getConfigTimezone() : 'UTC'; $adminTimeZone = new \DateTimeZone($timezone); $simpleRes = new \DateTime($date, $adminTimeZone); $simpleRes->setTimezone(new \DateTimeZone('UTC')); return $simpleRes; } catch (\Exception $e) { return null; } } return parent::_convertDate($date); }
/** * Convert given date to default (UTC) timezone * * @param string $date * @param string $locale * @return \Magento\Framework\Stdlib\DateTime\Date|null */ protected function _convertDate($date, $locale) { if ($this->getColumn()->getFilterTime()) { try { $dateObj = $this->_localeDate->date(null, null, $locale, false); //set default timezone for store (admin) $dateObj->setTimezone($this->_scopeConfig->getValue($this->_localeDate->getDefaultTimezonePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); //set date with applying timezone of store $dateObj->set($date, $this->_localeDate->getDateTimeFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT), $locale); //convert store date to default date in UTC timezone without DST $dateObj->setTimezone(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE); return $dateObj; } catch (\Exception $e) { return null; } } return parent::_convertDate($date, $locale); }