Skip to content

Commit efbe4de

Browse files
michaelwyldemageprince
authored andcommitted
Remove the timezone from the date when retrieving the current month from a UTC timestamp.
1 parent e43594e commit efbe4de

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
@@ -211,8 +211,11 @@ protected function _getMonthInterval(\DateTime $dateStart, \DateTime $dateEnd, $
211211
)
212212
);
213213
} else {
214+
// Transform the start date to UTC whilst preserving the date. This is required as getTimestamp()
215+
// is in UTC which may result in a different month from the original start date due to time zones.
216+
$dateStartUtc = (new \DateTime())->createFromFormat('d-m-Y g:i:s', $dateStart->format('d-m-Y 00:00:00'));
214217
$interval['end'] = $this->_localeDate->convertConfigTimeToUtc(
215-
$dateStart->format('Y-m-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59')
218+
$dateStart->format('Y-m-' . date('t', $dateStartUtc->getTimestamp()) . ' 23:59:59')
216219
);
217220
}
218221

0 commit comments

Comments
 (0)