本文整理汇总了PHP中Doctrine\DBAL\Platforms\AbstractPlatform::getDateFormatString方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPlatform::getDateFormatString方法的具体用法?PHP AbstractPlatform::getDateFormatString怎么用?PHP AbstractPlatform::getDateFormatString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Platforms\AbstractPlatform
的用法示例。
在下文中一共展示了AbstractPlatform::getDateFormatString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertToPHPValue
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;
}
示例2: convertToPHPValue
/**
* {@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;
}
示例3: convertToPHPValue
/**
* @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;
}
示例4: convertToPHPValue
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;
}
示例5: convertToDatabaseValue
/**
* @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);
}
示例6: convertToDatabaseValue
/** @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());
}
示例7: convertToPHPValue
/**
* @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;
}
示例8: convertToPHPValue
/**
* {@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;
}
示例9: convertToPHPValue
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return $value !== null ? \DateTime::createFromFormat('!' . $platform->getDateFormatString(), $value) : null;
}
示例10: convertToPHPValue
/**
* @param string|null $value
* @param AbstractPlatform $platform
* @return DateTime|null
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return $this->doConvertToPHPValue($value, $platform->getDateFormatString());
}