Skip to content

Commit f9aade8

Browse files
ENGCOM-2169: Remove the timezone from the date when retrieving the current month from a UTC timestamp. #16492
- Merge Pull Request #16492 from michaelwylde/magento2:2.3-develop-report-monthInterval - Merged commits: 1. 2482579
2 parents d9fb867 + 2482579 commit f9aade8

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)