當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateTimeZone::__construct方法代碼示例

本文整理匯總了PHP中DateTimeZone::__construct方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTimeZone::__construct方法的具體用法?PHP DateTimeZone::__construct怎麽用?PHP DateTimeZone::__construct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DateTimeZone的用法示例。


在下文中一共展示了DateTimeZone::__construct方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Constructor.
  *
  * @param string|DateTimeZone|PHPDateTimeZone|null $timezone [optional] The timezone as a string, or as
  *     DateTimeZone or PHPDateTimeZone instance. Null to use the default timezone.
  *
  * @throws Exception Throws an exception on failure.
  */
 public function __construct($timezone)
 {
     // Parse null
     if ($timezone === null) {
         $timezone = DateTimeZoneUtils::getDefaultTimezone();
     } else {
         if ($timezone instanceof DateTime) {
             $timezone = $timezone->getTimezone();
         } else {
             if ($timezone instanceof PHPDateTime) {
                 $timezone = $timezone->getTimezone();
             }
         }
     }
     // Parse DateTimeZone and PHPDateTimeZone instances
     if ($timezone instanceof parent) {
         parent::__construct($timezone->getName());
         return $this;
     }
     // Check if this is a valid timezone ID
     if (DateTimeZoneUtils::isValidTimezoneId($timezone)) {
         parent::__construct($timezone);
         return $this;
     }
     // Invalid timezone, throw an exception
     throw new Exception('Invalid timezone (\'' . $timezone . '\' was given)');
 }
開發者ID:timvisee,項目名稱:MohicanenPieGuesser,代碼行數:35,代碼來源:DateTimeZone.php

示例2: __construct

 /**
  * Initializes the {@link $name} property.
  *
  * @param string $timezone
  */
 public function __construct($timezone)
 {
     parent::__construct($timezone);
     $name = $this->getName();
     if ($name == 'utc') {
         $name = 'UTC';
     }
     $this->name = $name;
 }
開發者ID:icanboogie,項目名稱:datetime,代碼行數:14,代碼來源:TimeZone.php

示例3: __construct

 /**
  * CONSTRUCTOR
  * Build a new DateTimeZone object.
  * Store user timezone identifier in session.
  *
  * @since   0.0.1
  *
  * @see     getTimeZone()
  *
  * @access  public
  * @param   string|null $timezone   Optional. Timezone identifier to use. Default: null
  * @return  void
  */
 public function __construct($timezone = null)
 {
     if (null === $timezone) {
         $timezone = self::getTimeZone();
     }
     // Store timezone in session
     $_SESSION['timezone'] = $timezone;
     parent::__construct($timezone);
 }
開發者ID:codeschubser,項目名稱:honeycomb,代碼行數:22,代碼來源:DateTimeZone.php

示例4: __construct

 public function __construct($in_dtz = null)
 {
     $this->tz_defined = false;
     if (!isset($in_dtz)) {
         return;
     }
     $olson = olson_from_tzstring($in_dtz);
     if (isset($olson)) {
         try {
             parent::__construct($olson);
             $this->tz_defined = $olson;
         } catch (Exception $e) {
             dbg_error_log('ERROR', 'Could not handle timezone "%s" (%s) - will use floating time', $in_dtz, $olson);
             parent::__construct('UTC');
             $this->tz_defined = false;
         }
     } else {
         dbg_error_log('ERROR', 'Could not recognize timezone "%s" - will use floating time', $in_dtz);
         parent::__construct('UTC');
         $this->tz_defined = false;
     }
 }
開發者ID:derekyu1437,項目名稱:davical,代碼行數:22,代碼來源:RRule-v2.php


注:本文中的DateTimeZone::__construct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。