Skip to content

Commit 2482579

Browse files
committed
Remove the timezone from the date when retrieving the current month from a UTC timestamp.
1 parent d9fb867 commit 2482579

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/code/Magento/Reports/Model/ResourceModel/Report/Collection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ protected function _getMonthInterval(\DateTime $dateStart, \DateTime $dateEnd, $
215215
)
216216
);
217217
} else {
218+
// Transform the start date to UTC whilst preserving the date. This is required as getTimestamp()
219+
// is in UTC which may result in a different month from the original start date due to time zones.
220+
$dateStartUtc = (new \DateTime())->createFromFormat('d-m-Y g:i:s', $dateStart->format('d-m-Y 00:00:00'));
218221
$interval['end'] = $this->_localeDate->convertConfigTimeToUtc(
219-
$dateStart->format('Y-m-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59')
222+
$dateStart->format('Y-m-' . date('t', $dateStartUtc->getTimestamp()) . ' 23:59:59')
220223
);
221224
}
222225

0 commit comments

Comments
 (0)