/** * Retrieve time shift * * @param string $datetime * @return string */ public function timeShift($datetime) { return $this->_localeDate->utcDate(null, $datetime, true, \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); }
/** * Collect needed information from buy request * Then filter data * * @param \Magento\Framework\Object $buyRequest * @return $this * @throws \Magento\Framework\Model\Exception * @throws \Exception */ public function importBuyRequest(\Magento\Framework\Object $buyRequest) { $startDate = $buyRequest->getData(self::BUY_REQUEST_START_DATETIME); if ($startDate) { if (!$this->_localeDate || !$this->_store) { throw new \Exception('Locale and store instances must be set for this operation.'); } $dateFormat = $this->_localeDate->getDateTimeFormat(TimezoneInterface::FORMAT_TYPE_SHORT); $localeCode = $this->_localeResolver->getLocaleCode(); if (!\Zend_Date::isDate($startDate, $dateFormat, $localeCode)) { throw new \Magento\Framework\Model\Exception(__('The recurring payment start date has invalid format.')); } $utcTime = $this->_localeDate->utcDate($this->_store, $startDate, true, $dateFormat)->toString(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); $this->setStartDatetime($utcTime)->setImportedStartDatetime($startDate); } return $this->_filterValues(); }