2

we are facing a strange behavior for value of updated_at saved in db table sales_order. Server timezone is CEST, updated_at date therefor is saved in CEST to database. This is validated. Default config timezone is "Europe/Berlin".

Cron job collects orders with specific state via resource collection to manipulate them. Debugging updated_at value by looping result set prints value/date in UTC, its -2h. This runs in "crontab" environment/area. This happens (in loop) for all those calls:

echo $order->getUpdatedAt();
echo $order->getData('updated_at');
echo $order->getOrigData('updated_at'); 

//Collection load
$criteria = $this->criteriaBuilder->addFilter('state', Order::STATE_PAYMENT_REVIEW)->create();
$items = $this->orderRepository->getList($criteria)->getItems();

We checked mostly every possibility why and how this transformation happens but we didn't find any hint in code. We found no after collection load observer or any other forced transformation. Magento folks, what could cause this behavior?

Thanks in advance

  • have u build custom collection for your cronjob? – Amit Bera Sep 26 '18 at 12:02
  • Added collection load to my question. – sbothner_mzentrale Sep 26 '18 at 12:22
  • I guess that You have to changes time criteriaBuilder section. – Amit Bera Sep 26 '18 at 12:30
  • You think searchCriteriaBuilder modifies date format / timezones dynamically? – sbothner_mzentrale Sep 26 '18 at 13:41
0

after hours of debugging we found the issue. MySQL and server configured timezone is CEST. So all native queries done by PHP or direct mysql shows date in configured timezone CEST. All application based result sets doesn't because of following query fired in \Magento\Framework\DB\Adapter\Pdo\Mysql::_connect.

$this->_connection->query("SET time_zone = '+00:00'");

So internally Magento2 sets time_zone to UTC, what is fine but not known ;).

Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.