public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; } $val = \Psc\DateTime\Date::parse($platform->getDateFormatString(), $value); if (!$val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateFormatString()); } return $val; }
/** * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null || $value instanceof \DateTime) { return $value; } $val = \DateTime::createFromFormat('!' . $platform->getDateFormatString(), $value); if (!$val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateFormatString()); } return $val; }
/** * @param \DateTimeImmutable|string|null $value * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform * @return \DateTimeImmutable|null */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null || $value instanceof DateTimeImmutable) { return $value; } $dateTime = DateTimeImmutable::createFromFormat('!' . $platform->getDateFormatString(), $value); if ($dateTime === false) { throw \Doctrine\DBAL\Types\ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateFormatString()); } return $dateTime; }
public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; } $val = \Improvein\MssqlBundle\Types\ImproveinDateTime::createFromFormat('!' . $platform->getDateFormatString(), $value); if (!$val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateFormatString()); } return $val; }
/** * @param Date $value * @param AbstractPlatform $platform * * @return string */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { if ($value instanceof Date) { return $value->toDateTime()->format($platform->getDateFormatString()); } return parent::convertToDatabaseValue($value, $platform); }
/** @noinspection PhpMissingParentCallCommonInspection * @inheritdoc * * @SuppressWarnings(PHPMD.StaticAccess) */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { /** @var string|null|DateTime $value */ if ($value === null) { return null; } $dateTime = $value instanceof DateTime ? $value : DateTime::createFromFormat(static::JSON_API_FORMAT, $value); if ($dateTime === false) { throw ConversionException::conversionFailedFormat($value, $this->getName(), static::JSON_API_FORMAT); } return $dateTime->format($platform->getDateFormatString()); }
/** * @param $value * @param AbstractPlatform $platform * * @return \DateTime|mixed|null * @throws \Doctrine\DBAL\Types\ConversionException */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; } if (is_null(self::$utc)) { self::$utc = new \DateTimeZone('UTC'); } $val = \DateTime::createFromFormat($platform->getDateFormatString(), $value, self::$utc); if (!$val) { throw ConversionException::conversionFailed($value, $this->getName()); } return $val; }
/** * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; } $val = \DateTime::createFromFormat('!' . $platform->getDateFormatString(), $value, self::$utc ? self::$utc : (self::$utc = new \DateTimeZone('UTC'))); if (!$val) { throw ConversionException::conversionFailed($value, $this->getName()); } $errors = $val->getLastErrors(); // date was parsed to completely not valid value if ($errors['warning_count'] > 0 && (int) $val->format('Y') < 0) { return null; } return $val; }
public function convertToPHPValue($value, AbstractPlatform $platform) { return $value !== null ? \DateTime::createFromFormat('!' . $platform->getDateFormatString(), $value) : null; }
/** * @param string|null $value * @param AbstractPlatform $platform * @return DateTime|null */ public function convertToPHPValue($value, AbstractPlatform $platform) { return $this->doConvertToPHPValue($value, $platform->getDateFormatString()); }