本文整理匯總了PHP中Horde_Date::getTimezoneAlias方法的典型用法代碼示例。如果您正苦於以下問題:PHP Horde_Date::getTimezoneAlias方法的具體用法?PHP Horde_Date::getTimezoneAlias怎麽用?PHP Horde_Date::getTimezoneAlias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Horde_Date
的用法示例。
在下文中一共展示了Horde_Date::getTimezoneAlias方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getTimezone
/**
* Attempt to guess the timezone identifier from the $offsets array.
*
* Since it's impossible to know exactly which olson timezone name a
* specific set of offsets represent (multiple timezone names may be
* described by the same offsets for any given year) we allow passing an
* expected timezone. If this matches one of the timezones that matches the
* offsets, we return that. Otherwise, we attempt to get the full timezone
* name from Horde_Date and if that fails, return the abbreviated timezone
* name of the first timezone that matches the provided offsets.
*
* @param array|string $offsets The timezone to check. Either an array
* of offsets or an activesynz tz blob.
* @param string $expectedTimezone The expected timezone. If not empty, and
* present in the results, will return.
*
* @return string The timezone identifier.
*/
public function getTimezone($offsets, $expectedTimezone = null)
{
$timezones = $this->getListOfTimezones($offsets, $expectedTimezone);
if (isset($timezones[$expectedTimezone])) {
return $expectedTimezone;
} else {
return Horde_Date::getTimezoneAlias(current($timezones));
}
}
示例2: testGetTimezoneAlias
public function testGetTimezoneAlias()
{
$this->assertEquals('Europe/Berlin', Horde_Date::getTimezoneAlias('W. Europe Standard Time'));
$this->assertEquals('Europe/Berlin', Horde_Date::getTimezoneAlias('W. Europe'));
$this->assertEquals('Europe/Berlin', Horde_Date::getTimezoneAlias('CET'));
$this->assertEquals('UTC', Horde_Date::getTimezoneAlias('UTC'));
}
示例3: getZone
/**
* Returns an object representing an invidual timezone.
*
* Maps to a "Zone" entry in the timezone database. Works with
* zone aliases and other common timezone names too.
*
* @param string $zone A timezone name.
*
* @return Horde_Timezone_Zone A timezone object.
*/
public function getZone($zone)
{
if (!$this->_zones) {
$this->_extractAndParse();
}
$zone = Horde_Date::getTimezoneAlias($zone);
$alias = isset($this->_links[$zone]) ? $this->_links[$zone] : $zone;
if (!isset($this->_zones[$alias])) {
throw new Horde_Timezone_Exception(sprintf('Timezone %s not found', $zone));
}
$this->_zones[$alias]->setTzid($zone);
return $this->_zones[$alias];
}