src/Entity/Entity.php
protected function getDateTimeValueInstanceFrom($value)
    {
        if ($value === null) {
            return null;
        } elseif ($value instanceof DateTime) {
            return new DateTimeValue($value->format('Y-m-d H:i:s'), 'UTC');
        } else {
            return new DateTimeValue($value, 'UTC');
        }
    }
protected function getDateTimeValueInstanceFrom($value)
    {
        if ($value === null) {
            return null;
        } elseif ($value instanceof DateTime) {
            return new DateTimeValue($value->format('Y-m-d H:i:s'), 'UTC');
        } else {
            return new DateTimeValue($value, 'UTC');
        }
    }
Use input $value and return a valid DateTimeValue instance.

@param  mixed              $value
@return DateTimeValue|null