Use setTimeZone if this method exists.
The php version is not a critical factor to choose the method, but we have to use setTimeZone, if it exists.
This commit is contained in:
parent
7d7b583851
commit
0d6af5cd90
@ -267,8 +267,10 @@ class DateType extends AbstractType
|
|||||||
{
|
{
|
||||||
$pattern = $formatter->getPattern();
|
$pattern = $formatter->getPattern();
|
||||||
$timezone = $formatter->getTimezoneId();
|
$timezone = $formatter->getTimezoneId();
|
||||||
|
// Use it, if exists.
|
||||||
|
$setTimeZone = method_exists($formatter, 'setTimeZone');
|
||||||
|
|
||||||
if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
|
if ($setTimeZone) {
|
||||||
$formatter->setTimeZone('UTC');
|
$formatter->setTimeZone('UTC');
|
||||||
} else {
|
} else {
|
||||||
$formatter->setTimeZoneId('UTC');
|
$formatter->setTimeZoneId('UTC');
|
||||||
@ -286,7 +288,7 @@ class DateType extends AbstractType
|
|||||||
$formatter->setPattern($pattern);
|
$formatter->setPattern($pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
|
if ($setTimeZone) {
|
||||||
$formatter->setTimeZone($timezone);
|
$formatter->setTimeZone($timezone);
|
||||||
} else {
|
} else {
|
||||||
$formatter->setTimeZoneId($timezone);
|
$formatter->setTimeZoneId($timezone);
|
||||||
|
Reference in New Issue
Block a user