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


PHP DateTime::get方法代码示例

本文整理汇总了PHP中DateTime::get方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::get方法的具体用法?PHP DateTime::get怎么用?PHP DateTime::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTime的用法示例。


在下文中一共展示了DateTime::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getVersionPreview

 /**
  * @see Object\ClassDefinition\Data::getVersionPreview
  * @param \Zend_Date|\DateTime $data
  * @param null|Object\AbstractObject $object
  * @param mixed $params
  * @return string
  */
 public function getVersionPreview($data, $object = null, $params = [])
 {
     if ($data instanceof \Zend_Date) {
         return $data->get(\Zend_Date::DATE_MEDIUM);
     } elseif ($data instanceof \DateTimeInterface) {
         return $data->format("Y-m-d");
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:15,代码来源:Date.php

示例2: toLdapDateTime

 /**
  * Converts a date-entity to an LDAP-compatible date-string
  *
  * The date-entity <var>$date</var> can be either a timestamp, a
  * DateTime Object, a string that is parseable by strtotime() or a Zend_Date
  * Object.
  *
  * @param    integer|string|DateTimt|Zend_Date        $date    The date-entity
  * @param    boolean                                    $asUtc    Whether to return the LDAP-compatible date-string
  *                                                          as UTC or as local value
  * @return    string
  * @throws    InvalidArgumentException
  */
 public static function toLdapDateTime($date, $asUtc = true)
 {
     if (!$date instanceof DateTime) {
         if (is_int($date)) {
             $date = new DateTime('@' . $date);
             $date->setTimezone(new DateTimeZone(date_default_timezone_get()));
         } else {
             if (is_string($date)) {
                 $date = new DateTime($date);
             } else {
                 if ($date instanceof Zend_Date) {
                     $date = new DateTime($date->get(Zend_Date::ISO_8601));
                 } else {
                     throw new InvalidArgumentException('Parameter $date is not of the expected type');
                 }
             }
         }
     }
     $timezone = $date->format('O');
     if (true === $asUtc) {
         $date->setTimezone(new DateTimeZone('UTC'));
         $timezone = 'Z';
     }
     if ('+0000' === $timezone) {
         $timezone = 'Z';
     }
     return $date->format('YmdHis') . $timezone;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:41,代码来源:Converter.php

示例3: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->dateTime = DateTime::get()->setTimestamp('1432674145')->setTimezone(new \DateTimeZone('Europe/London'));
 }
开发者ID:colonB,项目名称:Copycat,代码行数:8,代码来源:DateTimeTest.php


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