<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.datetimezone.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'datetimezone.listidentifiers.php',
    1 => 'DateTimeZone::listIdentifiers',
    2 => 'Returns a numerically indexed array containing all defined timezone identifiers',
  ),
  'up' => 
  array (
    0 => 'class.datetimezone.php',
    1 => 'DateTimeZone',
  ),
  'prev' => 
  array (
    0 => 'datetimezone.listabbreviations.php',
    1 => 'DateTimeZone::listAbbreviations',
  ),
  'next' => 
  array (
    0 => 'class.dateinterval.php',
    1 => 'DateInterval',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/datetime/datetimezone/listidentifiers.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="datetimezone.listidentifiers" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DateTimeZone::listIdentifiers</h1>
  <h1 class="refname">timezone_identifiers_list</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">DateTimeZone::listIdentifiers</span> -- <span class="refname">timezone_identifiers_list</span> &mdash; <span class="dc-title">Returns a numerically indexed array containing all defined timezone identifiers</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-datetimezone.listidentifiers-description">
  <h3 class="title">Description</h3>
  <p class="para">Object-oriented style</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>DateTimeZone::listIdentifiers</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$timezoneGroup</code><span class="initializer"> = <strong><code><a href="class.datetimezone.php#datetimezone.constants.all">DateTimeZone::ALL</a></code></strong></span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$countryCode</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">Procedural style</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><a href="function.timezone-identifiers-list.php" class="methodname">timezone_identifiers_list</a></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$timezoneGroup</code><span class="initializer"> = <strong><code><a href="class.datetimezone.php#datetimezone.constants.all">DateTimeZone::ALL</a></code></strong></span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$countryCode</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="simpara">
   Return the list of <a href="https://en.wikipedia.org/wiki/Tz_database#Names_of_timezones" class="link external">&raquo;&nbsp;IANA Time Zone identifiers</a>.
  </p>

  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    It&#039;s possible to detect the client (browser) timezone with JavaScript using
    <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions#timezone" class="link external">&raquo;&nbsp;Intl.DateTimeFormat</a> or
    <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime#time_zones_and_offsets" class="link external">&raquo;&nbsp;Temporal.ZonedDateTime</a>.
   </span>
  </p></blockquote>

 </div>


 <div class="refsect1 parameters" id="refsect1-datetimezone.listidentifiers-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">timezoneGroup</code></dt>
     <dd>
      <p class="para">
       One of the <span class="classname"><a href="class.datetimezone.php" class="classname">DateTimeZone</a></span> class constants (or a combination).
      </p>
     </dd>
    
    
     <dt><code class="parameter">countryCode</code></dt>
     <dd>
      <p class="para">
       A two-letter (uppercase) ISO 3166-1 compatible country code.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <span class="simpara">
        This option is only used when <code class="parameter">timezoneGroup</code> is set to
        <strong><code><a href="class.datetimezone.php#datetimezone.constants.per-country">DateTimeZone::PER_COUNTRY</a></code></strong>.
       </span>
      </p></blockquote>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-datetimezone.listidentifiers-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the array of timezone identifiers. Only non-outdated items are
   returned. To get all, including outdated timezone identifiers, use the
   <code class="literal">DateTimeZone::ALL_WITH_BC</code> as value for
   <code class="parameter">timezoneGroup</code>.
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-datetimezone.listidentifiers-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.0.0</td>
       <td>
        Prior to this version, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> was returned on failure.
       </td>
      </tr>

      <tr>
       <td>7.1.0</td>
       <td>
        <code class="parameter">countryCode</code> is nullable now.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-datetimezone.listidentifiers-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 List identifiers with location comments</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$identifiers </span><span style="color: #007700">= </span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">listIdentifiers</span><span style="color: #007700">(</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">ALL</span><span style="color: #007700">);<br /><br />foreach (</span><span style="color: #0000BB">$identifiers </span><span style="color: #007700">as </span><span style="color: #0000BB">$tzid</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$tz </span><span style="color: #007700">= new </span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">(</span><span style="color: #0000BB">$tzid</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$comments </span><span style="color: #007700">= </span><span style="color: #0000BB">$tz</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getLocation</span><span style="color: #007700">()[</span><span style="color: #DD0000">'comments'</span><span style="color: #007700">];<br />    echo </span><span style="color: #0000BB">$tzid </span><span style="color: #007700">. </span><span style="color: #DD0000">" (" </span><span style="color: #007700">. (</span><span style="color: #0000BB">$comments </span><span style="color: #007700">?: </span><span style="color: #DD0000">'Whole region'</span><span style="color: #007700">) . </span><span style="color: #DD0000">")\n"</span><span style="color: #007700">;<br />}</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">America/Antigua (Whole region)
America/Araguaina (Tocantins)
America/Argentina/Buenos_Aires (Buenos Aires (BA, CF))
America/Argentina/Catamarca (Catamarca (CT), Chubut (CH))
America/Argentina/Cordoba (Argentina (most areas: CB, CC, CN, ER, FM, MN, SE, SF))
// (Output trimmed due to length)</pre>
</div>
    </div>
   </div>
  </p>

  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Example #2 Listing identifiers for a specific region</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$timezone_identifiers </span><span style="color: #007700">= </span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">listIdentifiers</span><span style="color: #007700">( </span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">ASIA </span><span style="color: #007700">);<br />for (</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i </span><span style="color: #007700">&lt; </span><span style="color: #0000BB">5</span><span style="color: #007700">; </span><span style="color: #0000BB">$i</span><span style="color: #007700">++) {<br />    echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$timezone_identifiers</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Asia/Aden
Asia/Almaty
Asia/Amman
Asia/Anadyr
Asia/Aqtau</pre>
</div>
    </div>
   </div>
  </p>

  <p class="para">
   <div class="example" id="example-3">
    <p><strong>Example #3 Listing identifiers for multiple regions</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$timezone_identifiers </span><span style="color: #007700">= </span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">listIdentifiers</span><span style="color: #007700">( </span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">ASIA </span><span style="color: #007700">| </span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">PACIFIC </span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">join</span><span style="color: #007700">( </span><span style="color: #DD0000">', '</span><span style="color: #007700">, </span><span style="color: #0000BB">$timezone_identifiers </span><span style="color: #007700">);</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Asia/Aden, Asia/Almaty, Asia/Amman, Asia/Anadyr, Asia/Aqtau, Asia/Aqtobe,
Asia/Ashgabat, Asia/Atyrau, Asia/Baghdad, Asia/Bahrain, Asia/Baku,
Asia/Bangkok, Asia/Barnaul, Asia/Beirut, Asia/Bishkek, Asia/Brunei,
Asia/Chita, Asia/Choibalsan, Asia/Colombo, Asia/Damascus, Asia/Dhaka,
Asia/Dili, Asia/Dubai, Asia/Dushanbe, Asia/Famagusta, Asia/Gaza, Asia/Hebron,
Asia/Ho_Chi_Minh, Asia/Hong_Kong, Asia/Hovd, Asia/Irkutsk, Asia/Jakarta,
Asia/Jayapura, Asia/Jerusalem, Asia/Kabul, Asia/Kamchatka, Asia/Karachi,
Asia/Kathmandu, Asia/Khandyga, Asia/Kolkata, Asia/Krasnoyarsk,
Asia/Kuala_Lumpur, Asia/Kuching, Asia/Kuwait, Asia/Macau, Asia/Magadan,
Asia/Makassar, Asia/Manila, Asia/Muscat, Asia/Nicosia, Asia/Novokuznetsk,
Asia/Novosibirsk, Asia/Omsk, Asia/Oral, Asia/Phnom_Penh, Asia/Pontianak,
Asia/Pyongyang, Asia/Qatar, Asia/Qostanay, Asia/Qyzylorda, Asia/Riyadh,
Asia/Sakhalin, Asia/Samarkand, Asia/Seoul, Asia/Shanghai, Asia/Singapore,
Asia/Srednekolymsk, Asia/Taipei, Asia/Tashkent, Asia/Tbilisi, Asia/Tehran,
Asia/Thimphu, Asia/Tokyo, Asia/Tomsk, Asia/Ulaanbaatar, Asia/Urumqi,
Asia/Ust-Nera, Asia/Vientiane, Asia/Vladivostok, Asia/Yakutsk, Asia/Yangon,
Asia/Yekaterinburg, Asia/Yerevan, Pacific/Apia, Pacific/Auckland,
Pacific/Bougainville, Pacific/Chatham, Pacific/Chuuk, Pacific/Easter,
Pacific/Efate, Pacific/Fakaofo, Pacific/Fiji, Pacific/Funafuti,
Pacific/Galapagos, Pacific/Gambier, Pacific/Guadalcanal, Pacific/Guam,
Pacific/Honolulu, Pacific/Kanton, Pacific/Kiritimati, Pacific/Kosrae,
Pacific/Kwajalein, Pacific/Majuro, Pacific/Marquesas, Pacific/Midway,
Pacific/Nauru, Pacific/Niue, Pacific/Norfolk, Pacific/Noumea,
Pacific/Pago_Pago, Pacific/Palau, Pacific/Pitcairn, Pacific/Pohnpei,
Pacific/Port_Moresby, Pacific/Rarotonga, Pacific/Saipan, Pacific/Tahiti,
Pacific/Tarawa, Pacific/Tongatapu, Pacific/Wake, Pacific/Wallis</pre>
</div>
    </div>
   </div>
  </p>

  <p class="para">
   <div class="example" id="example-4">
    <p><strong>Example #4 Listing identifiers for a single country</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$timezone_identifiers </span><span style="color: #007700">= </span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">listIdentifiers</span><span style="color: #007700">( </span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">PER_COUNTRY</span><span style="color: #007700">, </span><span style="color: #DD0000">"UA" </span><span style="color: #007700">);<br />foreach( </span><span style="color: #0000BB">$timezone_identifiers </span><span style="color: #007700">as </span><span style="color: #0000BB">$identifier </span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$identifier</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Europe/Kyiv
Europe/Simferopol
Europe/Uzhgorod
Europe/Zaporozhye</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-datetimezone.listidentifiers-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.timezone-abbreviations-list.php" class="function" rel="rdfs-seeAlso">timezone_abbreviations_list()</a> - Alias of DateTimeZone::listAbbreviations</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>