Skip to content

Commit bfdb18f

Browse files
committed
Set timezone on DateTime object not in constructor
Passing in the DateTimeZone object via the DateTime constructor defines what timezone the passed date string is and not converting the time
1 parent 1d1c2ea commit bfdb18f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ public function date($date = null, $locale = null, $useTimezone = true, $include
196196
public function scopeDate($scope = null, $date = null, $includeTime = false)
197197
{
198198
$timezone = $this->_scopeConfig->getValue($this->getDefaultTimezonePath(), $this->_scopeType, $scope);
199-
$date = new \DateTime(is_numeric($date) ? '@' . $date : $date, new \DateTimeZone($timezone));
199+
$date = new \DateTime(is_numeric($date) ? '@' . $date : $date);
200+
$date->setTimezone(new \DateTimeZone($timezone));
200201
if (!$includeTime) {
201202
$date->setTime(0, 0, 0);
202203
}

0 commit comments

Comments
 (0)