當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。