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


PHP JDate::__construct方法代码示例

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


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

示例1: __construct

 public function __construct($date = 'now', $withoffset = true)
 {
     parent::__construct($date);
     $offset = null;
     if ($withoffset) {
         $offset = self::getOffSet();
         $this->setTimeZone($offset);
     }
     // incase we need to add the dst, we can do it here.
     // $this->modify('-1 hours');
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:11,代码来源:helper.php

示例2: __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

示例3: __construct

 /**
  * Construct
  *
  * @param   string $date Date
  * @param   mixed  $tz   Timezone
  */
 public function __construct($date = 'now', $tz = null)
 {
     $app = JFactory::getApplication();
     $orig = $date;
     $date = $this->stripDays($date);
     /* not sure if this one needed?
      * $date = $this->monthToInt($date);
      */
     $date = $this->removeDashes($date);
     try {
         $dt = new DateTime($date);
     } catch (Exception $e) {
         JDEBUG ? $app->enqueueMessage('date format unknown for ' . $orig . ' replacing with today\'s date', 'notice') : '';
         $date = 'now';
         /* catches 'Failed to parse time string (ublingah!) at position 0 (u)' exception.
          * don't use this object
          */
     }
     // 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());
     }
     parent::__construct($date, $tz);
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:31,代码来源:date.php

示例4: __construct

 public function __construct($date = 'now', $tz = null)
 {
     $orig = $date;
     $date = $this->stripDays($date);
     //not sure if this one needed?
     //	$date = $this->monthToInt($date);
     $date = $this->removeDashes($date);
     try {
         $dt = new DateTime($date);
     } catch (Exception $e) {
         JError::raiseNotice(500, 'date format unknown for ' . $orig . ' replacing with todays date');
         $date = 'now';
         // catches 'Failed to parse time string (ublingah!) at position 0 (u)' exception.
         // don't use this object
     }
     // 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());
     }
     parent::__construct($date, $tz);
 }
开发者ID:rhotog,项目名称:fabrik,代码行数:22,代码来源:date.php

示例5: __construct

 public function __construct()
 {
     parent::__construct();
     $this->setDate('now');
     $this->_current = isset($this->_date) ? $this->_date : $this->format('U');
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:6,代码来源:datetime.php

示例6: __construct

 public function __construct()
 {
     parent::__construct();
     $this->setDate('now');
     $this->_current = $this->_date;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:6,代码来源:datetime.php


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