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


PHP JevDate::stz方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param	string	String in a format accepted by JevDate::strtotime(), defaults to "now".
  * @param	mixed	Time zone to be used for the date.
  * @return	void
  * @since	1.5
  *
  * @throws	JException
  */
 public function __construct($date = 'now', $tz = null)
 {
     // Create the base GMT and server time zone objects.
     if (empty(self::$gmt)) {
         //|| empty(self::$stz)) {
         self::$gmt = new DateTimeZone('GMT');
         //self::$stz = new DateTimeZone(@date_default_timezone_get());
     }
     // Must get this each time otherwise modules can't set their own timezone
     $compparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $jtz = $compparams->get("icaltimezonelive", "");
     if ($jtz != "") {
         self::$stz = new DateTimeZone($jtz);
     } else {
         self::$stz = new DateTimeZone(@date_default_timezone_get());
     }
     $this->mytz = self::$stz;
     // If the time zone object is not set, attempt to build it.
     if (!$tz instanceof DateTimeZone) {
         if ($tz === null) {
             $tz = self::$gmt;
         } elseif (is_numeric($tz) && !JevJoomlaVersion::isCompatible("3.0")) {
             // Translate from offset.
             $tz = new DateTimeZone(self::$offsets[(string) $tz]);
         } elseif (is_numeric($tz)) {
             if (!isset($this->offsets)) {
                 $this->offsets = array('-12' => 'Etc/GMT-12', '-11' => 'Pacific/Midway', '-10' => 'Pacific/Honolulu', '-9.5' => 'Pacific/Marquesas', '-9' => 'US/Alaska', '-8' => 'US/Pacific', '-7' => 'US/Mountain', '-6' => 'US/Central', '-5' => 'US/Eastern', '-4.5' => 'America/Caracas', '-4' => 'America/Barbados', '-3.5' => 'Canada/Newfoundland', '-3' => 'America/Buenos_Aires', '-2' => 'Atlantic/South_Georgia', '-1' => 'Atlantic/Azores', '0' => 'Europe/London', '1' => 'Europe/Amsterdam', '2' => 'Europe/Istanbul', '3' => 'Asia/Riyadh', '3.5' => 'Asia/Tehran', '4' => 'Asia/Muscat', '4.5' => 'Asia/Kabul', '5' => 'Asia/Karachi', '5.5' => 'Asia/Calcutta', '5.75' => 'Asia/Katmandu', '6' => 'Asia/Dhaka', '6.5' => 'Indian/Cocos', '7' => 'Asia/Bangkok', '8' => 'Australia/Perth', '8.75' => 'Australia/West', '9' => 'Asia/Tokyo', '9.5' => 'Australia/Adelaide', '10' => 'Australia/Brisbane', '10.5' => 'Australia/Lord_Howe', '11' => 'Pacific/Kosrae', '11.5' => 'Pacific/Norfolk', '12' => 'Pacific/Auckland', '12.75' => 'Pacific/Chatham', '13' => 'Pacific/Tongatapu', '14' => 'Pacific/Kiritimati');
             }
             // Translate from offset.
             $tz = new DateTimeZone($this->offsets[(string) $tz]);
         } elseif (is_string($tz)) {
             $tz = new DateTimeZone($tz);
         }
     }
     // If the date is numeric assume a unix timestamp and convert it.
     date_default_timezone_set('UTC');
     $date = is_numeric($date) ? date('c', $date) : $date;
     // fix potentiall bad date data
     if (strpos($date, ":") > 0 && strpos($date, "-") == false) {
         $date = str_replace(":", "", $date);
     }
     // Call the DateTime constructor
     parent::__construct($date, $tz);
     // reset the timezone !!
     date_default_timezone_set(self::$stz->getName());
     // Set the timezone object for access later.
     $this->_tz = $tz;
 }
开发者ID:madcsaba,项目名称:li-de,代码行数:58,代码来源:jevdate.php


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