diff --git a/src/View/Helper/DateFormat.php b/src/View/Helper/DateFormat.php index 23c76884..9c09708f 100644 --- a/src/View/Helper/DateFormat.php +++ b/src/View/Helper/DateFormat.php @@ -76,7 +76,7 @@ public function __invoke( } $timezone = $this->getTimezone(); - $formatterId = md5($dateType . "\0" . $timeType . "\0" . $locale ."\0" . $pattern); + $formatterId = md5($dateType . "\0" . $timeType . "\0" . $locale . "\0" . $pattern . "\0" . $timezone); if (! isset($this->formatters[$formatterId])) { $this->formatters[$formatterId] = new IntlDateFormatter( diff --git a/test/View/Helper/DateFormatTest.php b/test/View/Helper/DateFormatTest.php index adeca753..d3b342a6 100644 --- a/test/View/Helper/DateFormatTest.php +++ b/test/View/Helper/DateFormatTest.php @@ -286,4 +286,19 @@ public function getIntlDateFormatter($locale, $dateType, $timeType, $timezone, $ { return new IntlDateFormatter($locale, $dateType, $timeType, $timezone, null, $pattern); } + + public function testDifferentTimezone() + { + $helper = $this->helper; + + date_default_timezone_set('America/Chicago'); + $date = new DateTime('2018-01-01'); + + self::assertSame('Jan 1, 2018', $helper($date, IntlDateFormatter::MEDIUM)); + + date_default_timezone_set('America/New_York'); + $date = new DateTime('2018-01-01'); + + self::assertSame('Jan 1, 2018', $helper($date, IntlDateFormatter::MEDIUM)); + } }