• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar.php
  • Класс: CCalendar
  • Вызов: CCalendar::GetTimezoneList
static function GetTimezoneList()
{
	if (empty(self::$timezones))
	{
		self::$timezones = [];
		$aExcept = ["Etc/", "GMT", "UTC", "UCT", "HST", "PST", "MST", "CST", "EST", "CET", "MET", "WET", "EET", "PRC", "ROC", "ROK", "W-SU"];
		foreach(DateTimeZone::listIdentifiers() as $tz)
		{
			foreach($aExcept as $ex)
			{
				if(mb_strpos($tz, $ex) === 0)
				{
					continue 2;
				}
			}
			try
			{
				$oTz = new DateTimeZone($tz);
				self::$timezones[$tz] = array('timezone_id' => $tz, 'offset' => $oTz->getOffset(new DateTime("now", $oTz)));
			}
			catch(Exception $e){}
		}
		uasort(self::$timezones, function($a, $b){
			if($a['offset'] === $b['offset'])
			{
				return strcmp($a['timezone_id'], $b['timezone_id']);
			}
			return $a['offset'] < $b['offset']? -1 : 1;
		});

		foreach(self::$timezones as $k => $z)
		{
			self::$timezones[$k]['title'] = '(UTC'.($z['offset'] <> 0? ' '.($z['offset'] < 0? '-':'+').sprintf("%02d", ($h = floor(abs($z['offset'])/3600))).':'.sprintf("%02d", abs($z['offset'])/60 - $h*60) : '').') '.$z['timezone_id'];
		}
	}
	return self::$timezones;
}