Skip to content

Commit cc96ed2

Browse files
author
He, Joan(johe)
committed
Merge pull request #157 from magento-extensibility/MAGETWO-43960-custom-timezone-merged
[Extensibility] [Timezone] Magetwo 43960 custom timezone merged
2 parents 23c87b0 + 8198a2a commit cc96ed2

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ protected function _getFormat()
7575
public function render(\Magento\Framework\DataObject $row)
7676
{
7777
if ($data = $row->getData($this->getColumn()->getIndex())) {
78+
$timezone = $this->getColumn()->getTimezone() !== false ? $this->_localeDate->getConfigTimezone() : 'UTC';
7879
return $this->dateTimeFormatter->formatObject(
7980
$this->_localeDate->date(
80-
new \DateTime($data, new \DateTimeZone($this->_localeDate->getConfigTimezone()))
81+
new \DateTime(
82+
$data,
83+
new \DateTimeZone($timezone)
84+
)
8185
),
8286
$this->_getFormat()
8387
);

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ class Datetime extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra
2020
public function render(\Magento\Framework\DataObject $row)
2121
{
2222
$format = $this->getColumn()->getFormat();
23-
if ($data = $this->_getValue($row)) {
24-
return $this->_localeDate->formatDate(
25-
$data,
23+
if ($date = $this->_getValue($row)) {
24+
return $this->_localeDate->formatDateTime(
25+
$date instanceof \DateTimeInterface ? $date : new \DateTime($date),
2626
$format ?: \IntlDateFormatter::MEDIUM,
27-
true
27+
$format ?: \IntlDateFormatter::MEDIUM,
28+
null,
29+
$this->getColumn()->getTimezone() !== false ? null : 'UTC'
2830
);
2931
}
3032
return $this->getColumn()->getDefault();

0 commit comments

Comments
 (0)