From efbe4ded5fab22146996ead87d64b3327f628f8a Mon Sep 17 00:00:00 2001 From: Michael Wylde Date: Tue, 3 Jul 2018 12:24:47 +0930 Subject: [PATCH] Remove the timezone from the date when retrieving the current month from a UTC timestamp. --- .../Reports/Model/ResourceModel/Report/Collection.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Reports/Model/ResourceModel/Report/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Report/Collection.php index 7a107b79c0e83..13a764d1df738 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Report/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Report/Collection.php @@ -211,8 +211,11 @@ protected function _getMonthInterval(\DateTime $dateStart, \DateTime $dateEnd, $ ) ); } else { + // Transform the start date to UTC whilst preserving the date. This is required as getTimestamp() + // is in UTC which may result in a different month from the original start date due to time zones. + $dateStartUtc = (new \DateTime())->createFromFormat('d-m-Y g:i:s', $dateStart->format('d-m-Y 00:00:00')); $interval['end'] = $this->_localeDate->convertConfigTimeToUtc( - $dateStart->format('Y-m-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59') + $dateStart->format('Y-m-' . date('t', $dateStartUtc->getTimestamp()) . ' 23:59:59') ); }