Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f42c73f

Browse files
committed
[Form] Fix \IntlDateFormatter timezone parameter usage to bypass PHP bug #66323
1 parent aa04f35 commit f42c73f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ protected function getIntlDateFormatter($ignoreTimezone = false)
163163
$dateFormat = $this->dateFormat;
164164
$timeFormat = $this->timeFormat;
165165
$timezone = $ignoreTimezone ? 'UTC' : $this->outputTimezone;
166+
if (class_exists('IntlTimeZone', false)) {
167+
// see https://bugs.php.net/bug.php?id=66323
168+
$timezone = \IntlTimeZone::createTimeZone($timezone);
169+
}
166170
$calendar = $this->calendar;
167171
$pattern = $this->pattern;
168172

src/Symfony/Component/Form/Extension/Core/Type/DateType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
7777
\Locale::getDefault(),
7878
$dateFormat,
7979
$timeFormat,
80-
null,
80+
// see https://bugs.php.net/bug.php?id=66323
81+
class_exists('IntlTimeZone', false) ? \IntlTimeZone::createDefault() : null,
8182
$calendar,
8283
$pattern
8384
);

0 commit comments

Comments
 (0)