diff --git a/src/Dibi/Result.php b/src/Dibi/Result.php index 2ed2c009..fdc7ca3f 100644 --- a/src/Dibi/Result.php +++ b/src/Dibi/Result.php @@ -515,7 +515,7 @@ class Result implements IDataSource $row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F'; } elseif ($type === Type::DATETIME || $type === Type::DATE || $type === Type::TIME) { - if ((int) $value !== 0 || substr((string) $value, 0, 3) === '00:') { // '', NULL, FALSE, '0000-00-00', ... + if ($value && substr((string) $value, 0, 3) !== '000') { // '', NULL, FALSE, '0000-00-00', ... $value = new DateTime($value); $row[$key] = empty($this->formats[$type]) ? $value : $value->format($this->formats[$type]); } else { diff --git a/src/Dibi/Row.php b/src/Dibi/Row.php index 3ce0d4c1..0bb3dc0c 100644 --- a/src/Dibi/Row.php +++ b/src/Dibi/Row.php @@ -38,7 +38,7 @@ class Row implements \ArrayAccess, \IteratorAggregate, \Countable { $time = $this[$key]; if (!$time instanceof DateTime) { - if ((int) $time === 0 && substr((string) $time, 0, 3) !== '00:') { // '', NULL, FALSE, '0000-00-00', ... + if (!$time || substr((string) $time, 0, 3) === '000') { // '', NULL, FALSE, '0000-00-00', ... return NULL; } $time = new DateTime($time);