本文整理汇总了PHP中Jenssegers\Date\Date::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::instance方法的具体用法?PHP Date::instance怎么用?PHP Date::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jenssegers\Date\Date
的用法示例。
在下文中一共展示了Date::instance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertToPHPValue
public function convertToPHPValue($value, AbstractPlatform $platform)
{
$result = parent::convertToPHPValue($value, $platform);
if ($result instanceof \DateTime) {
return Date::instance($result);
}
return $result;
}
示例2: asDateTime
protected function asDateTime($value)
{
if (is_numeric($value)) {
return Date::createFromTimestamp($value);
} elseif (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) {
return Date::createFromFormat('Y-m-d', $value)->startOfDay();
} elseif (!$value instanceof DateTime) {
$format = $this->getDateFormat();
return Date::createFromFormat($format, $value);
}
return Date::instance($value);
}
示例3: asDateTime
/**
* Return a timestamp as DateTime object.
*
* @param mixed $value
* @return \Jenssegers\Date\Date
*/
protected function asDateTime($value)
{
// If this value is an integer, we will assume it is a UNIX timestamp's value
// and format a Carbon object from this timestamp. This allows flexibility
// when defining your date fields as they might be UNIX timestamps here.
if (is_numeric($value)) {
return Date::createFromTimestamp($value);
} elseif (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) {
return Date::createFromFormat('Y-m-d', $value)->startOfDay();
} elseif (!$value instanceof DateTime) {
$format = $this->getDateFormat();
return Date::createFromFormat($format, $value);
}
return Date::instance($value);
}
示例4: asDateTime
/**
* Return a timestamp as DateTime object.
*
* @param mixed $value
* @return \Carbon\Carbon
*/
protected function asDateTime($value)
{
Date::setLocale('it');
// 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) {
//
} elseif (is_numeric($value)) {
return Date::createFromTimestamp($value);
} elseif (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) {
return Date::createFromFormat('Y-m-d', $value)->startOfDay();
} elseif (!$value instanceof DateTime) {
$format = $this->getDateFormat();
return Date::createFromFormat($format, $value);
}
return Date::instance($value);
}