当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::instance方法代码示例

本文整理汇总了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;
 }
开发者ID:zetta-code,项目名称:tss-doctrineutil,代码行数:8,代码来源:JenssegersDateTimeType.php

示例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);
 }
开发者ID:ankhzet,项目名称:Ankh,代码行数:12,代码来源:DateAccessorTrait.php

示例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);
 }
开发者ID:qwildz,项目名称:localized-eloquent-date,代码行数:21,代码来源:LocalizedDateTrait.php

示例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);
 }
开发者ID:AssociazionePrometeo,项目名称:doorkeeper-web,代码行数:24,代码来源:LocalizesDates.php


注:本文中的Jenssegers\Date\Date::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。