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