diff --git a/src/ZfcDatagrid/Column/Type/DateTime.php b/src/ZfcDatagrid/Column/Type/DateTime.php index a1ef8a47..2cb4362a 100644 --- a/src/ZfcDatagrid/Column/Type/DateTime.php +++ b/src/ZfcDatagrid/Column/Type/DateTime.php @@ -175,19 +175,22 @@ public function getFilterDefaultOperation() /** * - * @param string $val + * @param mixed $val * @return string */ public function getFilterValue($val) { - $formatter = new IntlDateFormatter($this->getLocale(), $this->getOutputDateType(), $this->getOutputTimeType(), $this->getOutputTimezone(), IntlDateFormatter::GREGORIAN, $this->getOutputPattern()); - $timestamp = $formatter->parse($val); - - $date = new PhpDateTime(); - $date->setTimestamp($timestamp); - $date->setTimezone(new DateTimeZone($this->getSourceTimezone())); + if (!$val instanceof PhpDateTime) { + $formatter = new IntlDateFormatter($this->getLocale(), $this->getOutputDateType(), $this->getOutputTimeType(), $this->getOutputTimezone(), IntlDateFormatter::GREGORIAN, $this->getOutputPattern()); + $timestamp = $formatter->parse($val); + + $val = new PhpDateTime(); + $val->setTimestamp($timestamp); + } + + $val->setTimezone(new DateTimeZone($this->getSourceTimezone())); - return $date->format($this->getSourceDateTimeFormat()); + return $val->format($this->getSourceDateTimeFormat()); } /**