Object of class DateTime could not be converted to string

v2026.

I am using a standard MySQL DATE field, but I'm getting the following error:

Object of class DateTime could not be converted to string

The error appears to be coming from:

public function getViewValue(): string

{

 return $this->ViewValue instanceof Htmlable

 ? $this->ViewValue->toHtml()

 : (is_array($this->ViewValue)

 ? JsonEncode($this->ViewValue)

 : strval($this->ViewValue));

}

The field format is set to the default Date/Time format. I've also tried several other date formats, but I get the same error.

Has anyone come across this before or have any ideas what might be causing it?

Thanks.