Browse Source

Fixes #763: handling empty string for date formatting.

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
6e32fae378
  1. 6
      framework/yii/base/Formatter.php

6
framework/yii/base/Formatter.php

@ -314,11 +314,7 @@ class Formatter extends Component
protected function normalizeDatetimeValue($value)
{
if (is_string($value)) {
if (ctype_digit($value) || $value[0] === '-' && ctype_digit(substr($value, 1))) {
return (int)$value;
} else {
return strtotime($value);
}
return is_numeric($value) ? (int)$value : strtotime($value);
} elseif ($value instanceof DateTime) {
return $value->getTimestamp();
} else {

Loading…
Cancel
Save