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