本文整理匯總了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;
}