Commit d43c3396 by Qiang Xue

Formatter::timeZone should take string only.

parent a43f8b23
...@@ -28,12 +28,11 @@ use yii\helpers\Html; ...@@ -28,12 +28,11 @@ use yii\helpers\Html;
class Formatter extends Component class Formatter extends Component
{ {
/** /**
* @var string|\IntlTimeZone|\DateTimeZone the timezone to use for formatting time and date values. * @var string the timezone to use for formatting time and date values.
* This can be any value that may be passed to [date_default_timezone_set()](http://www.php.net/manual/en/function.date-default-timezone-set.php) * This can be any value that may be passed to [date_default_timezone_set()](http://www.php.net/manual/en/function.date-default-timezone-set.php)
* e.g. `UTC`, `Europe/Berlin` or `America/Chicago`. * e.g. `UTC`, `Europe/Berlin` or `America/Chicago`.
* Refer to the [php manual](http://www.php.net/manual/en/timezones.php) for available timezones. * Refer to the [php manual](http://www.php.net/manual/en/timezones.php) for available timezones.
* This can also be an IntlTimeZone or a DateTimeZone object. * If this property is not set, [[\yii\base\Application::timezone]] will be used.
* If not set, [[\yii\base\Application::timezone]] will be used.
*/ */
public $timeZone; public $timeZone;
/** /**
...@@ -344,7 +343,7 @@ class Formatter extends Component ...@@ -344,7 +343,7 @@ class Formatter extends Component
*/ */
protected function formatTimestamp($value, $format) protected function formatTimestamp($value, $format)
{ {
$date = new DateTime(null, is_string($this->timeZone) ? new \DateTimeZone($this->timeZone) : $this->timeZone); $date = new DateTime(null, new \DateTimeZone($this->timeZone));
$date->setTimestamp($value); $date->setTimestamp($value);
return $date->format($format); return $date->format($format);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment