Commit f8667f1a by Alexander Makarov

Merge pull request #2736 from ivokund/patch-1

Fixes #2735 - Formatter support for DateTimeInterface
parents 0013b608 f3a7c03f
...@@ -139,6 +139,7 @@ Yii Framework 2 Change Log ...@@ -139,6 +139,7 @@ Yii Framework 2 Change Log
- Enh #2646: Added support for specifying hostinfo in the pattern of a URL rule (qiangxue) - Enh #2646: Added support for specifying hostinfo in the pattern of a URL rule (qiangxue)
- Enh #2661: Added boolean column type support for SQLite (qiangxue) - Enh #2661: Added boolean column type support for SQLite (qiangxue)
- Enh #2670: Changed `console\Controller::globalOptions()` to `options($actionId)` to (make it possible to) differentiate options per action (hqx) - Enh #2670: Changed `console\Controller::globalOptions()` to `options($actionId)` to (make it possible to) differentiate options per action (hqx)
- Enh #2735: Added support for `DateTimeInterface` in `Formatter` (ivokund)
- Enh: Added support for using arrays as option values for console commands (qiangxue) - Enh: Added support for using arrays as option values for console commands (qiangxue)
- Enh: Added `favicon.ico` and `robots.txt` to default application templates (samdark) - Enh: Added `favicon.ico` and `robots.txt` to default application templates (samdark)
- Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue) - Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue)
......
...@@ -339,7 +339,7 @@ class Formatter extends Component ...@@ -339,7 +339,7 @@ class Formatter extends Component
{ {
if (is_string($value)) { if (is_string($value)) {
return is_numeric($value) || $value === '' ? (int)$value : strtotime($value); return is_numeric($value) || $value === '' ? (int)$value : strtotime($value);
} elseif ($value instanceof DateTime) { } elseif ($value instanceof DateTime || $value instanceof \DateTimeInterface) {
return $value->getTimestamp(); return $value->getTimestamp();
} else { } else {
return (int)$value; return (int)$value;
......
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