@param DateTime $value
@param Doctrine\DBAL\Platforms\AbstractPlatform $platform

@return string
760058
public function convertToDatabaseValue($value, AbstractPlatform $platform)
     {
         if ($value === null) {
             return;
         }
         $formatString = $platform->getDateTimeFormatString();

         $formatted = $value->setTimezone(new \DateTimeZone('UTC'))->format($formatString);

         return $formatted;
     }
1092700
protected function getDateTime($value)
    {
        try {
            if ($this->isTestingRelativeDateTime($value)) {
                return Date::parse($value);
            }

            return new DateTime($value);
        } catch (Exception $e) {
            //
        }
    }
128307
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return null;
        }

        if (static::$basePath !== '' && \strpos($value->getPathname(), static::$basePath) !== 0) {
            throw new \LogicException(\sprintf('Invalid path or "basePath" ("%s") configuration', static::$basePath));
        }

        return \substr($value->getPathname(), \strlen(static::$basePath));
    }
455161
public function getDateTime(int $value): DateTime
    {
        if ($value > 9999999999) { // microseconds it is
            $value = floor($value / 1000000);
        }

        return DateTime::createFromFormat("U", $value);
    }
394422
protected function processDateTime(\DateTimeInterface $value)
    {
        $newDateTime = \DateTimeImmutable::createFromFormat(
                'Y-m-d H:i:s',
                $value->format('Y-m-d H:i:s'),
                $value->getTimezone()
        );

        return DateTimeProcessor::zeroUnusedParts($this->type->getMode(), $newDateTime);
    }
762491
public function fromDateTime($value)
    {
        $format = $this->getDateFormat();

        // If the value is already a DateTime instance, we will just skip the rest of
        // these checks since they will be a waste of time, and hinder performance
        // when checking the field. We will just return the DateTime right away.
        if ($value instanceof DateTime)
        {
            //
        }

        // If the value is totally numeric, we will assume it is a UNIX timestamp and
        // format the date as such. Once we have the date in DateTime form we will
        // format it according to the proper format for the database connection.
        elseif (is_numeric($value))
        {
            $value = Carbon::createFromTimestamp($value);
        }

        // If the value is in simple year, month, day format, we will format it using
        // that setup. This is for simple "date" fields which do not have hours on
        // the field. This conveniently picks up those dates and format correct.
        elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $value))
        {
            $value = Carbon::createFromFormat('Y-m-d', $value)->startOfDay();
        }

        // If this value is some other type of string, we'll create the DateTime with
        // the format used by the database connection. Once we get the instance we
        // can return back the finally formatted DateTime instances to the devs.
        elseif ( ! $value instanceof DateTime)
        {
            $value = Carbon::createFromFormat($format, $value);
        }

        return $value->format($format);
    }
108556
private function toDateTimeObject($value)
    {
        $datetime = null;
        
        switch (true) {
            case $value instanceof \DateTime:
                $datetime = new DateTime($value->format(\DateTime::RFC3339));
                break;
            case is_numeric($value):
                $datetime = new DateTime(sprintf('@%d', $value));
                break;
            case is_string($value):
                $datetime = new DateTime($value);
                break;
        }
        
        return $datetime;
    }
1298191
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (null === $value || '' === $value) {
            return $value;
        }

        if ( ! $value instanceof Email) {
            $type = is_object($value) ? get_class($value) : gettype($value);
            throw new \InvalidArgumentException(sprintf('You have to pass an object of kind \SerendipityHQ\Component\ValueObjects\Email\Email to use the Doctrine type EmailType. "%s" passed instead.', $type));
        }

        // Validate the $value as a valid email
        $validator = new EmailValidator();

        if ( ! $validator->isValid($value, new RFCValidation())) {
            throw new \InvalidArgumentException(sprintf('An email field accepts only valid email addresses. The value "%s" is not a valid email.', $value));
        }

        // The value is automatically transformed into a string thans to the __toString() method
        return $value;
    }
1221646
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if (!$value) {
            return null;
        }

        if ($platform instanceof MySqlPlatform) {
            $data = sscanf($value, 'POINT(%f %f)');
        } else {
            $data = sscanf($value, "(%f,%f)");
        }

        return new Point($data[0], $data[1]);
    }
704643
public function convertToDatabaseValue($value, AbstractPlatform $platform): int
    {
        \assert('is_int($value)');
        if (!isset($this->getValues()[$value])) {
            throw new \InvalidArgumentException('Invalid type.');
        }
        return $value;
    }
1282555
public function quote($value)
    {
        if ($value === null) {
            return 'NULL';
        }
        if ($value instanceof DateTimeInterface) {
            return $this->pdo->quote($value->format('Y-m-d H:i:s'));
        }
        if (is_array($value)) {
            return implode(',', array_map([$this, 'quote'], $value));
        }
        if (is_bool($value)) {
            return $this->pdo->quote($value ? 1 : 0);
        }

        return $this->pdo->quote($value);
    }
654199
public function buildDateTimeRawValue(\DateTime $dateTime = null) {
		if (null === $dateTime) return null;
		return DateUtils::formatDateTime($dateTime, SqliteDateTimeColumn::FORMAT_DATE_TIME);
	}
1296623
public function convertToPHPValueSql($value, AbstractPlatform $platform)
    {
        $opts = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;

        if (is_object($value)) {
            if (method_exists($value, 'toJson')) {
                $value = $value->toJson();
            } elseif (method_exists($value, 'toArray')) {
                $value = json_encode($value->toArray(), $opts);
            } else {
                $value = json_encode($value, $opts);
            }
        }

        return parent::convertToPHPValueSql($value, $platform);
    }
970197
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

        if ($value instanceof Uuid || Uuid::isValid($value)) {
            return (string) $value;
        }

        throw ConversionException::conversionFailed($value, self::NAME);
    }
219881
final public static function resolveValue($value, AbstractPlatform $platform)
    {
        if ($value instanceof DomainId) {
            $class = \get_class($value);
            $type = Type::INTEGER;

            foreach (self::$mapping as $mapping) {
                if ($class === $mapping['class']) {
                    $type = $mapping['data_type'] ?? $type;
                    break;
                }
            }

            return self::getType($type)->convertToPHPValue($value->isEmpty() ? null : $value->toString(), $platform);
        }

        return $value;
    }
183606
protected function convert_to_date_time( $value ) {

		if ( $value instanceof \DateTimeInterface ) {
			return $value;
		}

		switch ( gettype( $value ) ) {
			case 'string' :
				return $this->convert_string( $value );
			case 'integer' :
				return $this->convert_integer( $value );
			case 'double' :
				return $this->convert_double( $value );
			case 'array' :
				return $this->convert_array( $value );
		}

		$this->error_code = Error\ErrorLoggerInterface::INVALID_TYPE_NON_DATE;

		return FALSE;
	}
1131035
protected function databaseValue($value)
    {
        if (!$value instanceof \DateTime) {
            throw ODMException::conversionFailedInvalidType($value, Type::DATE, ['null', 'DateTime']);
        }

        $this->setToMidnight($value);

        return (string)$value->getTimestamp();
    }