Documentation

TimeZone extends DateTimeZone
in package

This class provides some methods to simplify working with time zones.

Table of Contents

Constants

DST_ALWAYS  = 2
Uses DST throughout the entire year.
DST_NEVER  = 0
Never uses DST.
DST_SWITCHES  = 1
Uses DST for some parts of the year, and not for other parts.

Properties

$fallbacks  : array<string|int, mixed>
$metazones  : array<string|int, mixed>
$sorted_tzids  : array<string|int, mixed>
$metazone_transitions  : array<string|int, mixed>
$prioritized_tzids  : array<string|int, mixed>
$ranges  : array<string|int, mixed>
$timezones_when  : array<string|int, mixed>

Methods

getAbbreviations()  : array<string|int, mixed>
Returns this time zone's abbreviations (if any).
getDstType()  : int
Returns whether this time zone uses Daylight Saving Time.
getLabel()  : string
Returns the localized name of this time zone's location.
getMetaZone()  : string
Returns the "meta-zone" for this time zone at the given timestamp.
getMetaZoneLabel()  : string
Returns the "meta-zone" label for this time zone at the given timestamp.
getSortedTzidsForCountry()  : array<string|int, mixed>
Returns an array of all the time zones in a country, ranked according to population and/or political significance.
getStandardOffset()  : int
Returns the Standard Time offset from GMT, ignoring any Daylight Saving Time that might be in effect.
getTzidFallbacks()  : array<string|int, mixed>
Checks a list of time zone identifiers to make sure they are all defined in the installed version of the time zone database, and returns an array of key-value substitution pairs.
getTzidMetazones()  : array<string|int, mixed>
Returns an array that instructs SMF how to map specific time zones (e.g. "America/Denver") onto the user-friendly "meta-zone" labels that most people think of as time zones (e.g. "Mountain Time").
list()  : array<string|int, mixed>
Get a list of time zones.
validateIsoCountryCodes()  : array<string|int, mixed>|string
Validates a set of two-character ISO 3166-1 country codes.
buildMetaZoneTransitions()  : void
Builds a list of time zone transitions for all "meta-zones" starting from $when until one year later.
getTimeRange()  : array<string|int, mixed>
Given a start time in any format that strtotime can understand, gets the Unix timestamps for a date range starting then and ending one year later.
prioritizeTzids()  : void
Sorts time zone identifiers into a prioritized list based on the country codes in Config::$modSettings['timezone_priority_countries'].

Constants

DST_ALWAYS

Uses DST throughout the entire year.

public mixed DST_ALWAYS = 2

DST_NEVER

Never uses DST.

public mixed DST_NEVER = 0

DST_SWITCHES

Uses DST for some parts of the year, and not for other parts.

public mixed DST_SWITCHES = 1

Properties

$fallbacks

public static array<string|int, mixed> $fallbacks = [ /* * 1. Simple renames. * * PHP_INT_MIN because these are valid for all dates. */ 'Pacific/Kanton' => [['ts' => PHP_INT_MIN, 'tzid' => 'Pacific/Enderbury']], 'Europe/Kyiv' => [['ts' => PHP_INT_MIN, 'tzid' => 'Europe/Kiev']], /* * 2. Newly created time zones. * * The initial entry in many of the following zones is set to '' because * the records go back to eras before the adoption of standardized time * zones, which means no substitutes are possible then. */ // Diverged from America/Ojinaga in version 2022g. 'America/Ciudad_Juarez' => [['ts' => PHP_INT_MIN, 'tzid' => ''], ['ts' => '1922-01-01T07:00:00+0000', 'tzid' => 'America/Ojinaga'], ['ts' => '2022-11-30T06:00:00+0000', 'tzid' => 'America/Denver']], ]

Time zone fallbacks to use when PHP has an outdated copy of the time zone database.

'ts' is the timestamp when the substitution first becomes valid. 'tzid' is the alternative time zone identifier to use.

$metazones

public static array<string|int, mixed> $metazones = [ // No DST 'Africa/Abidjan' => 'GMT', // No DST 'Africa/Algiers' => 'Europe_Central', // Uses DST 'Africa/Casablanca' => 'Africa_Morocco', // No DST 'Africa/Johannesburg' => 'Africa_South', // No DST 'Africa/Lagos' => 'Africa_West', // No DST 'Africa/Maputo' => 'Africa_Central', // No DST 'Africa/Nairobi' => 'Africa_East', // Uses DST 'America/Adak' => 'North_America_Hawaii_Aleutian', // Uses DST 'America/Anchorage' => 'North_America_Alaska', // No DST 'America/Argentina/Buenos_Aires' => 'South_America_Argentina', // Uses DST 'America/Asuncion' => 'South_America_Paraguay', // No DST 'America/Belize' => 'North_America_Central', // No DST 'America/Bogota' => 'South_America_Colombia', // No DST 'America/Caracas' => 'South_America_Venezuela', // No DST 'America/Cayenne' => 'South_America_French_Guiana', // Uses DST 'America/Chicago' => 'North_America_Central', // Uses DST 'America/Chihuahua' => 'North_America_Mexico_Pacific', // Uses DST 'America/Denver' => 'North_America_Mountain', // Uses DST 'America/Nuuk' => 'North_America_Greenland_Western', // No DST 'America/Guayaquil' => 'South_America_Ecuador', // No DST 'America/Guyana' => 'South_America_Guyana', // Uses DST 'America/Halifax' => 'North_America_Atlantic', // Uses DST 'America/Havana' => 'North_America_Cuba', // No DST 'America/Jamaica' => 'North_America_Eastern', // No DST 'America/La_Paz' => 'South_America_Bolivia', // No DST 'America/Lima' => 'South_America_Peru', // Uses DST 'America/Los_Angeles' => 'North_America_Pacific', // No DST 'America/Manaus' => 'South_America_Amazon', // Uses DST 'America/Mexico_City' => 'North_America_Mexico_Central', // Uses DST 'America/Miquelon' => 'North_America_St_Pierre_Miquelon', // No DST 'America/Montevideo' => 'South_America_Uruguay', // Uses DST 'America/New_York' => 'North_America_Eastern', // No DST 'America/Noronha' => 'South_America_Noronha', // No DST 'America/Paramaribo' => 'South_America_Suriname', // No DST 'America/Phoenix' => 'North_America_Mountain', // No DST 'America/Port_of_Spain' => 'North_America_Atlantic', // No DST 'America/Punta_Arenas' => 'South_America_Chile_Magallanes', // No DST 'America/Rio_Branco' => 'South_America_Acre', // Uses DST 'America/Santiago' => 'South_America_Chile', // No DST 'America/Sao_Paulo' => 'South_America_Brasilia', // Uses DST 'America/Scoresbysund' => 'North_America_Greenland_Eastern', // Uses DST 'America/St_Johns' => 'North_America_Newfoundland', // No DST 'Antarctica/Casey' => 'Antarctica_Casey', // No DST 'Antarctica/Davis' => 'Antarctica_Davis', // No DST 'Antarctica/DumontDUrville' => 'Antarctica_DumontDUrville', // No DST 'Antarctica/Macquarie' => 'Antarctica_Macquarie', // No DST 'Antarctica/Mawson' => 'Antarctica_Mawson', // Uses DST 'Antarctica/McMurdo' => 'Antarctica_McMurdo', // No DST 'Antarctica/Palmer' => 'Antarctica_Palmer', // No DST 'Antarctica/Rothera' => 'Antarctica_Rothera', // No DST 'Antarctica/Syowa' => 'Antarctica_Syowa', // Uses DST 'Antarctica/Troll' => 'Antarctica_Troll', // No DST 'Antarctica/Vostok' => 'Antarctica_Vostok', // No DST 'Asia/Almaty' => 'Asia_Kazakhstan_Eastern', // Uses DST 'Asia/Amman' => 'Asia_Jordan', // No DST 'Asia/Aqtau' => 'Asia_Kazakhstan_Western', // No DST 'Asia/Ashgabat' => 'Asia_Turkmenistan', // No DST 'Asia/Baku' => 'Asia_Azerbaijan', // No DST 'Asia/Bangkok' => 'Asia_Southeast', // Uses DST 'Asia/Beirut' => 'Asia_Libya', // No DST 'Asia/Bishkek' => 'Asia_Kyrgystan', // No DST 'Asia/Brunei' => 'Asia_Brunei', // Uses DST 'Asia/Damascus' => 'Asia_Damascus', // No DST 'Asia/Dhaka' => 'Asia_Bangladesh', // No DST 'Asia/Dili' => 'Asia_East_Timor', // No DST 'Asia/Dubai' => 'Asia_Gulf', // No DST 'Asia/Dushanbe' => 'Asia_Tajikistan', // Uses DST 'Asia/Gaza' => 'Asia_Palestine', // No DST 'Asia/Hong_Kong' => 'Asia_Hong_Kong', // No DST 'Asia/Hovd' => 'Asia_Mongolia_Western', // No DST 'Asia/Irkutsk' => 'Asia_Irkutsk', // No DST 'Asia/Jakarta' => 'Asia_Indonesia_Western', // No DST 'Asia/Jayapura' => 'Asia_Indonesia_Eastern', // Uses DST 'Asia/Jerusalem' => 'Asia_Israel', // No DST 'Asia/Kabul' => 'Asia_Afghanistan', // No DST 'Asia/Kamchatka' => 'Asia_Kamchatka', // No DST 'Asia/Karachi' => 'Asia_Pakistan', // No DST 'Asia/Kathmandu' => 'Asia_Nepal', // No DST 'Asia/Kolkata' => 'Asia_India', // No DST 'Asia/Krasnoyarsk' => 'Asia_Krasnoyarsk', // No DST 'Asia/Kuala_Lumpur' => 'Asia_Malaysia', // No DST 'Asia/Magadan' => 'Asia_Magadan', // No DST 'Asia/Makassar' => 'Asia_Indonesia_Central', // No DST 'Asia/Manila' => 'Asia_Philippines', // No DST 'Asia/Omsk' => 'Asia_Omsk', // No DST 'Asia/Riyadh' => 'Asia_Arabia', // No DST 'Asia/Seoul' => 'Asia_Korea', // No DST 'Asia/Shanghai' => 'Asia_China', // No DST 'Asia/Singapore' => 'Asia_Singapore', // No DST 'Asia/Taipei' => 'Asia_Taiwan', // No DST 'Asia/Tashkent' => 'Asia_Uzbekistan', // No DST 'Asia/Tbilisi' => 'Asia_Georgia', // Uses DST 'Asia/Tehran' => 'Asia_Iran', // No DST 'Asia/Thimphu' => 'Asia_Bhutan', // No DST 'Asia/Tokyo' => 'Asia_Japan', // No DST 'Asia/Ulaanbaatar' => 'Asia_Mongolia_Eastern', // No DST 'Asia/Vladivostok' => 'Asia_Vladivostok', // No DST 'Asia/Yakutsk' => 'Asia_Yakutsk', // No DST 'Asia/Yangon' => 'Asia_Myanmar', // No DST 'Asia/Yekaterinburg' => 'Asia_Yekaterinburg', // No DST 'Asia/Yerevan' => 'Asia_Armenia', // Uses DST 'Atlantic/Azores' => 'Atlantic_Azores', // No DST 'Atlantic/Cape_Verde' => 'Atlantic_Cape_Verde', // No DST 'Atlantic/South_Georgia' => 'Atlantic_South_Georgia', // No DST 'Atlantic/Stanley' => 'Atlantic_Falkland', // Uses DST 'Australia/Adelaide' => 'Australia_Central', // No DST 'Australia/Brisbane' => 'Australia_Eastern', // No DST 'Australia/Darwin' => 'Australia_Central', // No DST 'Australia/Eucla' => 'Australia_CentralWestern', // Uses DST 'Australia/Lord_Howe' => 'Australia_Lord_Howe', // Uses DST 'Australia/Melbourne' => 'Australia_Eastern', // No DST 'Australia/Perth' => 'Australia_Western', // Uses DST 'Europe/Berlin' => 'Europe_Central', // Uses DST 'Europe/Chisinau' => 'Europe_Moldova', // Uses DST 'Europe/Dublin' => 'Europe_Eire', // Uses DST 'Europe/Helsinki' => 'Europe_Eastern', // No DST 'Europe/Istanbul' => 'Asia_Turkey', // No DST 'Europe/Kaliningrad' => 'Europe_Eastern', // Uses DST 'Europe/Lisbon' => 'Europe_Western', // Uses DST 'Europe/London' => 'Europe_UK', // No DST 'Europe/Minsk' => 'Europe_Minsk', // No DST 'Europe/Moscow' => 'Europe_Moscow', // No DST 'Europe/Samara' => 'Europe_Samara', // No DST 'Europe/Volgograd' => 'Europe_Volgograd', // No DST 'Indian/Chagos' => 'Indian_Chagos', // No DST 'Indian/Christmas' => 'Indian_Christmas', // No DST 'Indian/Cocos' => 'Indian_Cocos', // No DST 'Indian/Kerguelen' => 'Indian_Kerguelen', // No DST 'Indian/Mahe' => 'Indian_Seychelles', // No DST 'Indian/Maldives' => 'Indian_Maldives', // No DST 'Indian/Mauritius' => 'Indian_Mauritius', // No DST 'Indian/Reunion' => 'Indian_Reunion', // Uses DST 'Pacific/Apia' => 'Pacific_Apia', // Uses DST 'Pacific/Auckland' => 'Pacific_New_Zealand', // No DST 'Pacific/Bougainville' => 'Pacific_Bougainville', // Uses DST 'Pacific/Chatham' => 'Pacific_Chatham', // No DST 'Pacific/Chuuk' => 'Pacific_Chuuk', // Uses DST 'Pacific/Easter' => 'Pacific_Easter', // No DST 'Pacific/Efate' => 'Pacific_Vanuatu', // No DST 'Pacific/Kanton' => 'Pacific_Phoenix_Islands', // No DST 'Pacific/Fakaofo' => 'Pacific_Tokelau', // Uses DST 'Pacific/Fiji' => 'Pacific_Fiji', // No DST 'Pacific/Funafuti' => 'Pacific_Tuvalu', // No DST 'Pacific/Galapagos' => 'Pacific_Galapagos', // No DST 'Pacific/Gambier' => 'Pacific_Gambier', // No DST 'Pacific/Guadalcanal' => 'Pacific_Solomon', // No DST 'Pacific/Guam' => 'Pacific_Chamorro', // No DST 'Pacific/Honolulu' => 'Pacific_Hawaii', // No DST 'Pacific/Kiritimati' => 'Pacific_Line', // No DST 'Pacific/Kwajalein' => 'Pacific_Marshall', // No DST 'Pacific/Marquesas' => 'Pacific_Marquesas', // No DST 'Pacific/Nauru' => 'Pacific_Nauru', // No DST 'Pacific/Niue' => 'Pacific_Niue', // No DST 'Pacific/Norfolk' => 'Pacific_Norfolk', // No DST 'Pacific/Noumea' => 'Pacific_New_Caledonia', // No DST 'Pacific/Pago_Pago' => 'Pacific_Samoa', // No DST 'Pacific/Palau' => 'Pacific_Palau', // No DST 'Pacific/Pitcairn' => 'Pacific_Pitcairn', // No DST 'Pacific/Pohnpei' => 'Pacific_Pohnpei', // No DST 'Pacific/Port_Moresby' => 'Pacific_Papua_New_Guinea', // No DST 'Pacific/Rarotonga' => 'Pacific_Cook', // No DST 'Pacific/Tahiti' => 'Pacific_Tahiti', // No DST 'Pacific/Tarawa' => 'Pacific_Gilbert', // No DST 'Pacific/Tongatapu' => 'Pacific_Tonga', // No DST 'Pacific/Wake' => 'Pacific_Wake', // No DST 'Pacific/Wallis' => 'Pacific_Wallis', ]

This array lists a series of representative time zones and their corresponding "meta-zone" labels.

The term "representative" here means that a given time zone can represent others that use exactly the same rules for DST transitions, UTC offsets, and abbreviations. For example, Europe/Berlin can be representative for Europe/Rome, Europe/Paris, etc., because these cities all use exactly the same time zone rules and values.

Meta-zone labels are the user friendly strings shown to the end user, e.g. "Mountain Standard Time". The values of this array are keys of strings defined in Timezones.{language}.php, which in turn are sprintf format strings used to generate the final label text.

Sometimes several representative time zones will map onto the same meta-zone label. This usually happens when there are different rules for Daylight Saving time in locations that are otherwise the same. For example, both America/Denver and America/Phoenix map to North_America_Mountain, but the ultimate output will be 'Mountain Time (MST/MDT)' for America/Denver vs. 'Mountain Standard Time (MST)' for America/Phoenix.

If you are adding a new meta-zone to this list because the TZDB added a new time zone that doesn't fit any existing meta-zone, please also add a fallback in the get_tzid_fallbacks() function. This helps support SMF installs on servers using outdated versions of the TZDB.

$sorted_tzids

public static array<string|int, mixed> $sorted_tzids = [ // '??' means international. '??' => ['UTC'], 'AD' => ['Europe/Andorra'], 'AE' => ['Asia/Dubai'], 'AF' => ['Asia/Kabul'], 'AG' => ['America/Antigua'], 'AI' => ['America/Anguilla'], 'AL' => ['Europe/Tirane'], 'AM' => ['Asia/Yerevan'], 'AO' => ['Africa/Luanda'], 'AQ' => [ // Sorted based on summer population. 'Antarctica/McMurdo', 'Antarctica/Casey', 'Antarctica/Davis', 'Antarctica/Mawson', 'Antarctica/Rothera', 'Antarctica/Syowa', 'Antarctica/Palmer', 'Antarctica/Troll', 'Antarctica/DumontDUrville', 'Antarctica/Vostok', ], 'AR' => ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Tucuman', 'America/Argentina/Salta', 'America/Argentina/Jujuy', 'America/Argentina/La_Rioja', 'America/Argentina/San_Luis', 'America/Argentina/Catamarca', 'America/Argentina/Mendoza', 'America/Argentina/San_Juan', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuaia'], 'AS' => ['Pacific/Pago_Pago'], 'AT' => ['Europe/Vienna'], 'AU' => ['Australia/Sydney', 'Australia/Melbourne', 'Australia/Brisbane', 'Australia/Perth', 'Australia/Adelaide', 'Australia/Hobart', 'Australia/Darwin', 'Australia/Broken_Hill', 'Australia/Currie', 'Australia/Lord_Howe', 'Australia/Eucla', 'Australia/Lindeman', 'Antarctica/Macquarie'], 'AW' => ['America/Aruba'], 'AX' => ['Europe/Mariehamn'], 'AZ' => ['Asia/Baku'], 'BA' => ['Europe/Sarajevo'], 'BB' => ['America/Barbados'], 'BD' => ['Asia/Dhaka'], 'BE' => ['Europe/Brussels'], 'BF' => ['Africa/Ouagadougou'], 'BG' => ['Europe/Sofia'], 'BH' => ['Asia/Bahrain'], 'BI' => ['Africa/Bujumbura'], 'BJ' => ['Africa/Porto-Novo'], 'BL' => ['America/St_Barthelemy'], 'BM' => ['Atlantic/Bermuda'], 'BN' => ['Asia/Brunei'], 'BO' => ['America/La_Paz'], 'BQ' => ['America/Kralendijk'], 'BR' => ['America/Sao_Paulo', 'America/Bahia', 'America/Fortaleza', 'America/Manaus', 'America/Recife', 'America/Belem', 'America/Maceio', 'America/Campo_Grande', 'America/Cuiaba', 'America/Porto_Velho', 'America/Rio_Branco', 'America/Boa_Vista', 'America/Santarem', 'America/Araguaina', 'America/Eirunepe', 'America/Noronha'], 'BS' => ['America/Nassau'], 'BT' => ['Asia/Thimphu'], 'BW' => ['Africa/Gaborone'], 'BY' => ['Europe/Minsk'], 'BZ' => ['America/Belize'], 'CA' => ['America/Toronto', 'America/Vancouver', 'America/Edmonton', 'America/Winnipeg', 'America/Halifax', 'America/Regina', 'America/St_Johns', 'America/Moncton', 'America/Thunder_Bay', 'America/Whitehorse', 'America/Glace_Bay', 'America/Yellowknife', 'America/Swift_Current', 'America/Dawson_Creek', 'America/Goose_Bay', 'America/Iqaluit', 'America/Creston', 'America/Fort_Nelson', 'America/Inuvik', 'America/Atikokan', 'America/Rankin_Inlet', 'America/Nipigon', 'America/Cambridge_Bay', 'America/Pangnirtung', 'America/Dawson', 'America/Blanc-Sablon', 'America/Rainy_River', 'America/Resolute'], 'CC' => ['Indian/Cocos'], 'CD' => ['Africa/Kinshasa', 'Africa/Lubumbashi'], 'CF' => ['Africa/Bangui'], 'CG' => ['Africa/Brazzaville'], 'CH' => ['Europe/Zurich'], 'CI' => ['Africa/Abidjan'], 'CK' => ['Pacific/Rarotonga'], 'CL' => ['America/Santiago', 'America/Punta_Arenas', 'Pacific/Easter'], 'CM' => ['Africa/Douala'], 'CN' => ['Asia/Shanghai', 'Asia/Urumqi'], 'CO' => ['America/Bogota'], 'CR' => ['America/Costa_Rica'], 'CU' => ['America/Havana'], 'CV' => ['Atlantic/Cape_Verde'], 'CW' => ['America/Curacao'], 'CX' => ['Indian/Christmas'], 'CY' => ['Asia/Nicosia', 'Asia/Famagusta'], 'CZ' => ['Europe/Prague'], 'DE' => ['Europe/Berlin', 'Europe/Busingen'], 'DJ' => ['Africa/Djibouti'], 'DK' => ['Europe/Copenhagen'], 'DM' => ['America/Dominica'], 'DO' => ['America/Santo_Domingo'], 'DZ' => ['Africa/Algiers'], 'EC' => ['America/Guayaquil', 'Pacific/Galapagos'], 'EE' => ['Europe/Tallinn'], 'EG' => ['Africa/Cairo'], 'EH' => ['Africa/El_Aaiun'], 'ER' => ['Africa/Asmara'], 'ES' => ['Europe/Madrid', 'Atlantic/Canary', 'Africa/Ceuta'], 'ET' => ['Africa/Addis_Ababa'], 'FI' => ['Europe/Helsinki'], 'FJ' => ['Pacific/Fiji'], 'FK' => ['Atlantic/Stanley'], 'FM' => ['Pacific/Chuuk', 'Pacific/Kosrae', 'Pacific/Pohnpei'], 'FO' => ['Atlantic/Faroe'], 'FR' => ['Europe/Paris'], 'GA' => ['Africa/Libreville'], 'GB' => ['Europe/London'], 'GD' => ['America/Grenada'], 'GE' => ['Asia/Tbilisi'], 'GF' => ['America/Cayenne'], 'GG' => ['Europe/Guernsey'], 'GH' => ['Africa/Accra'], 'GI' => ['Europe/Gibraltar'], 'GL' => ['America/Nuuk', 'America/Thule', 'America/Scoresbysund', 'America/Danmarkshavn'], 'GM' => ['Africa/Banjul'], 'GN' => ['Africa/Conakry'], 'GP' => ['America/Guadeloupe'], 'GQ' => ['Africa/Malabo'], 'GR' => ['Europe/Athens'], 'GS' => ['Atlantic/South_Georgia'], 'GT' => ['America/Guatemala'], 'GU' => ['Pacific/Guam'], 'GW' => ['Africa/Bissau'], 'GY' => ['America/Guyana'], 'HK' => ['Asia/Hong_Kong'], 'HN' => ['America/Tegucigalpa'], 'HR' => ['Europe/Zagreb'], 'HT' => ['America/Port-au-Prince'], 'HU' => ['Europe/Budapest'], 'ID' => ['Asia/Jakarta', 'Asia/Makassar', 'Asia/Pontianak', 'Asia/Jayapura'], 'IE' => ['Europe/Dublin'], 'IL' => ['Asia/Jerusalem'], 'IM' => ['Europe/Isle_of_Man'], 'IN' => ['Asia/Kolkata'], 'IO' => ['Indian/Chagos'], 'IQ' => ['Asia/Baghdad'], 'IR' => ['Asia/Tehran'], 'IS' => ['Atlantic/Reykjavik'], 'IT' => ['Europe/Rome'], 'JE' => ['Europe/Jersey'], 'JM' => ['America/Jamaica'], 'JO' => ['Asia/Amman'], 'JP' => ['Asia/Tokyo'], 'KE' => ['Africa/Nairobi'], 'KG' => ['Asia/Bishkek'], 'KH' => ['Asia/Phnom_Penh'], 'KI' => ['Pacific/Tarawa', 'Pacific/Kiritimati', 'Pacific/Kanton', 'Pacific/Enderbury'], 'KM' => ['Indian/Comoro'], 'KN' => ['America/St_Kitts'], 'KP' => ['Asia/Pyongyang'], 'KR' => ['Asia/Seoul'], 'KW' => ['Asia/Kuwait'], 'KY' => ['America/Cayman'], 'KZ' => ['Asia/Almaty', 'Asia/Aqtobe', 'Asia/Atyrau', 'Asia/Qostanay', 'Asia/Qyzylorda', 'Asia/Aqtau', 'Asia/Oral'], 'LA' => ['Asia/Vientiane'], 'LB' => ['Asia/Beirut'], 'LC' => ['America/St_Lucia'], 'LI' => ['Europe/Vaduz'], 'LK' => ['Asia/Colombo'], 'LR' => ['Africa/Monrovia'], 'LS' => ['Africa/Maseru'], 'LT' => ['Europe/Vilnius'], 'LU' => ['Europe/Luxembourg'], 'LV' => ['Europe/Riga'], 'LY' => ['Africa/Tripoli'], 'MA' => ['Africa/Casablanca'], 'MC' => ['Europe/Monaco'], 'MD' => ['Europe/Chisinau'], 'ME' => ['Europe/Podgorica'], 'MF' => ['America/Marigot'], 'MG' => ['Indian/Antananarivo'], 'MH' => ['Pacific/Majuro', 'Pacific/Kwajalein'], 'MK' => ['Europe/Skopje'], 'ML' => ['Africa/Bamako'], 'MM' => ['Asia/Yangon'], 'MN' => ['Asia/Ulaanbaatar', 'Asia/Choibalsan', 'Asia/Hovd'], 'MO' => ['Asia/Macau'], 'MP' => ['Pacific/Saipan'], 'MQ' => ['America/Martinique'], 'MR' => ['Africa/Nouakchott'], 'MS' => ['America/Montserrat'], 'MT' => ['Europe/Malta'], 'MU' => ['Indian/Mauritius'], 'MV' => ['Indian/Maldives'], 'MW' => ['Africa/Blantyre'], 'MX' => ['America/Mexico_City', 'America/Tijuana', 'America/Monterrey', 'America/Ciudad_Juarez', 'America/Chihuahua', 'America/Merida', 'America/Hermosillo', 'America/Cancun', 'America/Matamoros', 'America/Mazatlan', 'America/Bahia_Banderas', 'America/Ojinaga'], 'MY' => ['Asia/Kuala_Lumpur', 'Asia/Kuching'], 'MZ' => ['Africa/Maputo'], 'NA' => ['Africa/Windhoek'], 'NC' => ['Pacific/Noumea'], 'NE' => ['Africa/Niamey'], 'NF' => ['Pacific/Norfolk'], 'NG' => ['Africa/Lagos'], 'NI' => ['America/Managua'], 'NL' => ['Europe/Amsterdam'], 'NO' => ['Europe/Oslo'], 'NP' => ['Asia/Kathmandu'], 'NR' => ['Pacific/Nauru'], 'NU' => ['Pacific/Niue'], 'NZ' => ['Pacific/Auckland', 'Pacific/Chatham'], 'OM' => ['Asia/Muscat'], 'PA' => ['America/Panama'], 'PE' => ['America/Lima'], 'PF' => ['Pacific/Tahiti', 'Pacific/Marquesas', 'Pacific/Gambier'], 'PG' => ['Pacific/Port_Moresby', 'Pacific/Bougainville'], 'PH' => ['Asia/Manila'], 'PK' => ['Asia/Karachi'], 'PL' => ['Europe/Warsaw'], 'PM' => ['America/Miquelon'], 'PN' => ['Pacific/Pitcairn'], 'PR' => ['America/Puerto_Rico'], 'PS' => ['Asia/Gaza', 'Asia/Hebron'], 'PT' => ['Europe/Lisbon', 'Atlantic/Madeira', 'Atlantic/Azores'], 'PW' => ['Pacific/Palau'], 'PY' => ['America/Asuncion'], 'QA' => ['Asia/Qatar'], 'RE' => ['Indian/Reunion'], 'RO' => ['Europe/Bucharest'], 'RS' => ['Europe/Belgrade'], 'RU' => ['Europe/Moscow', 'Asia/Novosibirsk', 'Asia/Yekaterinburg', 'Europe/Samara', 'Asia/Omsk', 'Asia/Krasnoyarsk', 'Europe/Volgograd', 'Europe/Saratov', 'Asia/Barnaul', 'Europe/Ulyanovsk', 'Asia/Irkutsk', 'Asia/Vladivostok', 'Asia/Tomsk', 'Asia/Novokuznetsk', 'Europe/Astrakhan', 'Europe/Kirov', 'Europe/Kaliningrad', 'Asia/Chita', 'Asia/Yakutsk', 'Asia/Sakhalin', 'Asia/Kamchatka', 'Asia/Magadan', 'Asia/Anadyr', 'Asia/Khandyga', 'Asia/Ust-Nera', 'Asia/Srednekolymsk'], 'RW' => ['Africa/Kigali'], 'SA' => ['Asia/Riyadh'], 'SB' => ['Pacific/Guadalcanal'], 'SC' => ['Indian/Mahe'], 'SD' => ['Africa/Khartoum'], 'SE' => ['Europe/Stockholm'], 'SG' => ['Asia/Singapore'], 'SH' => ['Atlantic/St_Helena'], 'SI' => ['Europe/Ljubljana'], 'SJ' => ['Arctic/Longyearbyen'], 'SK' => ['Europe/Bratislava'], 'SL' => ['Africa/Freetown'], 'SM' => ['Europe/San_Marino'], 'SN' => ['Africa/Dakar'], 'SO' => ['Africa/Mogadishu'], 'SR' => ['America/Paramaribo'], 'SS' => ['Africa/Juba'], 'ST' => ['Africa/Sao_Tome'], 'SV' => ['America/El_Salvador'], 'SX' => ['America/Lower_Princes'], 'SY' => ['Asia/Damascus'], 'SZ' => ['Africa/Mbabane'], 'TC' => ['America/Grand_Turk'], 'TD' => ['Africa/Ndjamena'], 'TF' => ['Indian/Kerguelen'], 'TG' => ['Africa/Lome'], 'TH' => ['Asia/Bangkok'], 'TJ' => ['Asia/Dushanbe'], 'TK' => ['Pacific/Fakaofo'], 'TL' => ['Asia/Dili'], 'TM' => ['Asia/Ashgabat'], 'TN' => ['Africa/Tunis'], 'TO' => ['Pacific/Tongatapu'], 'TR' => ['Europe/Istanbul'], 'TT' => ['America/Port_of_Spain'], 'TV' => ['Pacific/Funafuti'], 'TW' => ['Asia/Taipei'], 'TZ' => ['Africa/Dar_es_Salaam'], 'UA' => ['Europe/Kyiv', 'Europe/Zaporozhye', 'Europe/Simferopol', 'Europe/Uzhgorod'], 'UG' => ['Africa/Kampala'], 'UM' => ['Pacific/Midway', 'Pacific/Wake'], 'US' => ['America/New_York', 'America/Los_Angeles', 'America/Chicago', 'America/Denver', 'America/Phoenix', 'America/Indiana/Indianapolis', 'America/Detroit', 'America/Kentucky/Louisville', 'Pacific/Honolulu', 'America/Anchorage', 'America/Boise', 'America/Juneau', 'America/Indiana/Vincennes', 'America/Sitka', 'America/Menominee', 'America/Indiana/Tell_City', 'America/Kentucky/Monticello', 'America/Nome', 'America/Indiana/Knox', 'America/North_Dakota/Beulah', 'America/Indiana/Winamac', 'America/Indiana/Petersburg', 'America/Indiana/Vevay', 'America/Metlakatla', 'America/North_Dakota/New_Salem', 'America/Indiana/Marengo', 'America/Yakutat', 'America/North_Dakota/Center', 'America/Adak'], 'UY' => ['America/Montevideo'], 'UZ' => ['Asia/Tashkent', 'Asia/Samarkand'], 'VA' => ['Europe/Vatican'], 'VC' => ['America/St_Vincent'], 'VE' => ['America/Caracas'], 'VG' => ['America/Tortola'], 'VI' => ['America/St_Thomas'], 'VN' => ['Asia/Ho_Chi_Minh'], 'VU' => ['Pacific/Efate'], 'WF' => ['Pacific/Wallis'], 'WS' => ['Pacific/Apia'], 'YE' => ['Asia/Aden'], 'YT' => ['Indian/Mayotte'], 'ZA' => ['Africa/Johannesburg'], 'ZM' => ['Africa/Lusaka'], 'ZW' => ['Africa/Harare'], ]

This array lists all the individual time zones in each country, sorted by population (as reported in statistics available on Wikipedia in November 2020). Sorting this way enables us to consistently select the most appropriate individual time zone to represent all others that share its DST transition rules and values. For example, this ensures that New York will be preferred over random small towns in Indiana.

If future versions of the time zone database add new time zone identifiers beyond those included here, they should be added to this list as appropriate. However, SMF will gracefully handle unexpected new time zones, so nothing will break in the meantime.

$metazone_transitions

protected static array<string|int, mixed> $metazone_transitions = []

List of time zone transitions for all "meta-zones" starting from a given value of $when until one year later.

Built by self::buildMetaZoneTransitions()

$prioritized_tzids

protected static array<string|int, mixed> $prioritized_tzids = []

Time zone identifiers sorted into a prioritized list based on the country codes in Config::$modSettings['timezone_priority_countries'].

Built by self::prioritizeTzids()

$ranges

protected static array<string|int, mixed> $ranges = []

Multidimensional array containing start and end timestamps for any given value of $when.

Built by self::getTimeRange()

$timezones_when

protected static array<string|int, mixed> $timezones_when = []

Multidimensional array containing compiled lists of selectable time zones for any given value of $when.

Built by self::list()

Methods

getAbbreviations()

Returns this time zone's abbreviations (if any).

public getAbbreviations([string $when = 'now' ]) : array<string|int, mixed>
Parameters
$when : string = 'now'

The date/time we are interested in. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
array<string|int, mixed>

The time zone's abbreviations.

getDstType()

Returns whether this time zone uses Daylight Saving Time.

public getDstType([int|string $when = 'now' ]) : int
Parameters
$when : int|string = 'now'

The earliest date/time we are interested in. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
int

One of this class's three DST_* constants.

getLabel()

Returns the localized name of this time zone's location.

public getLabel() : string

This method typically just returns the $txt string for this time zone. If there is no $txt string, guesses based on the time zone's raw name.

Return values
string

Localized name of this time zone's location.

getMetaZone()

Returns the "meta-zone" for this time zone at the given timestamp.

public getMetaZone([string $when = 'now' ]) : string
Parameters
$when : string = 'now'

The date/time we are interested in. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
string

The $tztxt variable for this time zone's "meta-zone".

getMetaZoneLabel()

Returns the "meta-zone" label for this time zone at the given timestamp.

public getMetaZoneLabel([string $when = 'now' ]) : string
Parameters
$when : string = 'now'

The date/time we are interested in. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
string

The $tztxt value for this time zone's "meta-zone".

getSortedTzidsForCountry()

Returns an array of all the time zones in a country, ranked according to population and/or political significance.

public static getSortedTzidsForCountry(string $country_code[, int|string $when = 'now' ]) : array<string|int, mixed>
Parameters
$country_code : string

The two-character ISO-3166 code for a country.

$when : int|string = 'now'

The date/time used to determine fallback values. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
array<string|int, mixed>

An array relating time zones to "meta-zones"

getStandardOffset()

Returns the Standard Time offset from GMT, ignoring any Daylight Saving Time that might be in effect.

public getStandardOffset([int|string $when = 'now' ]) : int
Parameters
$when : int|string = 'now'

The earliest date/time we are interested in. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
int

This time zone's Standard Time offset from GMT.

getTzidFallbacks()

Checks a list of time zone identifiers to make sure they are all defined in the installed version of the time zone database, and returns an array of key-value substitution pairs.

public static getTzidFallbacks(array<string|int, mixed> $tzids[, int|string $when = 'now' ]) : array<string|int, mixed>

For defined time zone identifiers, the substitution value will be identical to the original value. For undefined ones, the substitute will be a time zone identifier that was equivalent to the missing one at the specified time, or an empty string if there was no equivalent at that time.

Note: These fallbacks do not need to include every new time zone ever. They only need to cover any that are used in self::$metazones.

To find the date & time when a new time zone comes into effect, check the TZDB changelog at https://data.iana.org/time-zones/tzdb/NEWS

Parameters
$tzids : array<string|int, mixed>

The time zone identifiers to check.

$when : int|string = 'now'

The date/time used to determine substitute values. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
array<string|int, mixed>

Substitute values for any missing time zone identifiers.

getTzidMetazones()

Returns an array that instructs SMF how to map specific time zones (e.g. "America/Denver") onto the user-friendly "meta-zone" labels that most people think of as time zones (e.g. "Mountain Time").

public static getTzidMetazones([int|string $when = 'now' ]) : array<string|int, mixed>
Parameters
$when : int|string = 'now'

The date/time used to determine fallback values. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
array<string|int, mixed>

An array relating time zones to "meta-zones"

list()

Get a list of time zones.

public static list([int|string $when = 'now' ]) : array<string|int, mixed>
Parameters
$when : int|string = 'now'

The date/time for which to calculate the time zone values. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
array<string|int, mixed>

An array of time zone identifiers and label text.

validateIsoCountryCodes()

Validates a set of two-character ISO 3166-1 country codes.

public static validateIsoCountryCodes(array<string|int, mixed>|string $country_codes[, bool $as_csv = false ]) : array<string|int, mixed>|string
Parameters
$country_codes : array<string|int, mixed>|string

Array or CSV string of country codes.

$as_csv : bool = false

If true, return CSV string instead of array.

Return values
array<string|int, mixed>|string

Array or CSV string of valid country codes.

buildMetaZoneTransitions()

Builds a list of time zone transitions for all "meta-zones" starting from $when until one year later.

protected static buildMetaZoneTransitions([string $when = 'now' ]) : void
Parameters
$when : string = 'now'

The date/time used to determine substitute values. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

getTimeRange()

Given a start time in any format that strtotime can understand, gets the Unix timestamps for a date range starting then and ending one year later.

protected static getTimeRange([string $when = 'now' ]) : array<string|int, mixed>
Parameters
$when : string = 'now'

The date/time used to determine substitute values. May be a Unix timestamp or any string that strtotime() can understand. Defaults to 'now'.

Return values
array<string|int, mixed>

The start and end timestamps, in that order.

prioritizeTzids()

Sorts time zone identifiers into a prioritized list based on the country codes in Config::$modSettings['timezone_priority_countries'].

protected static prioritizeTzids() : void

Result is saved in self::$prioritized_tzids.


        
On this page

Search results