timezone_identifiers_list

timezone_identifiers_list(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array

Returns every IANA timezone identifier the environment can pick from (procedural alias of DateTimeZone::listIdentifiers), filterable by DateTimeZone::ALL/AFRICA/AMERICA/… groups or PER_COUNTRY plus a country code; pairs with date_timezone_set_get's "set a zone" side — list first, then set.

C C23

C23
/* no zone-list API: the inventory IS the zoneinfo directory - walk it
   (POSIX layout; Windows has no system tzdata at all) */
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>

int main(void) {
    DIR *d = opendir("/usr/share/zoneinfo");
    if (!d) {
        puts("no zoneinfo dir");
        return 0;
    }
    struct dirent *e;
    int n = 0;
    while ((e = readdir(d)) != NULL) {
        if (e->d_name[0] != '.') {
            n++;
        }
    }
    closedir(d);
    printf("%d\n", n > 0); /* inventory non-empty */
    printf("%d\n", access("/usr/share/zoneinfo/UTC", F_OK) == 0); /* UTC listed */
    return 0;
}
Output
1
1

C++ C++26

C++26
#include <filesystem>
#include <iostream>

// no zone-list API: the inventory IS the zoneinfo directory - walk it
// (C++20 std::chrono::tzdb_list is the standard answer, but clang's libc++
// does not ship the tzdb enabled on this toolchain; GCC's libstdc++ does)
int main() {
    std::filesystem::path dir{"/usr/share/zoneinfo"};
    std::size_t n = 0;
    for (auto const &entry : std::filesystem::directory_iterator(dir)) {
        ++n;
    }
    std::cout << (n > 0) << "\n";              // inventory non-empty
    std::cout << std::filesystem::exists(dir / "UTC") << "\n"; // UTC listed
    return 0;
}
Output
1
1

C# v11.0.100

v11.0.100
using System;
using System.Collections.Generic;
using System.Linq;

// TimeZoneInfo.GetSystemTimeZones(): the OS tzdata inventory .NET can pick from
var zones = TimeZoneInfo.GetSystemTimeZones();
Console.WriteLine(zones.Count > 10); // inventory plausible (derived fact, machine-independent)
var ids = zones.Select(z => z.Id).ToHashSet();
Console.WriteLine(ids.Any(id => id.Contains("UTC"))); // UTC shows up (as Etc/UTC on some OSes)
Console.WriteLine(ids.Contains("Asia/Shanghai"));
Output
True
True
True

Go v1.27.4

v1.27.4
package main

import (
	"fmt"
	"time"
)

// std has no zone-list API: the inventory lives in the system zoneinfo
// directory, and LoadLocation resolves ids one at a time (list tools are
// third-party; import _ "time/tzdata" embeds the database at build time)
func main() {
	utc, err := time.LoadLocation("UTC")
	fmt.Println(err == nil, utc.String())
	sh, err2 := time.LoadLocation("Asia/Shanghai")
	fmt.Println(err2 == nil)
	fmt.Println(sh.String())
}
Output
true UTC
true
Asia/Shanghai

Java v27.0.1

v27.0.1
import java.time.ZoneId;

public class Main {
    public static void main(String[] args) {
        // ZoneId.getAvailableZoneIds(): the IANA inventory bundled with the JDK tzdb
        var zones = ZoneId.getAvailableZoneIds();
        System.out.println(zones.contains("UTC"));
        System.out.println(zones.size() > 100); // derived fact, machine-independent
        System.out.println(zones.contains("Asia/Shanghai"));
    }
}
Output
true
true
true

JavaScript v26.13.1

v26.13.1
// Intl.supportedValuesOf("timeZone"): the inventory JS engines ship (ES2022)
// note: aliases like "UTC" are not listed - canonical zone ids only
const zones = Intl.supportedValuesOf("timeZone");
console.log(zones.includes("Asia/Shanghai"));
console.log(zones.length > 100); // derived fact, machine-independent
Output
true
true

PHP v8.6.0

v8.6.0
// timezone_identifiers_list(): the IANA zone-id inventory this process can
// pick from (procedural alias of DateTimeZone::listIdentifiers(); the
// object-side pair is date_timezone_set_get - list first, then set)
$ids = timezone_identifiers_list();
echo in_array("UTC", $ids, true) ? "UTC listed\n" : "UTC missing\n"; // derived fact: UTC is always in the inventory
echo count($ids) > 100 ? "inventory > 100\n" : "inventory too small\n"; // derived fact: hundreds of ids ship
$cn = timezone_identifiers_list(DateTimeZone::PER_COUNTRY, "CN");
sort($cn);
echo $cn[0] === "Asia/Shanghai" ? "CN zones start at Asia/Shanghai\n" : "unexpected: {$cn[0]}\n";
var_dump(timezone_identifiers_list() === DateTimeZone::listIdentifiers()); // the alias is 1:1
Output
UTC listed
inventory > 100
CN zones start at Asia/Shanghai
bool(true)

Python v3.15.2

v3.15.2
from zoneinfo import available_timezones

# available_timezones(): the IANA inventory Python can pick from (PEP 615, 3.9+)
zones = available_timezones()
print("UTC" in zones)
print(len(zones) > 100)           # derived fact, machine-independent
print("Asia/Shanghai" in zones)
Output
True
True
True

Rust v1.99.1

v1.99.1
// std has no timezone database - real projects embed chrono-tz (IANA data
// compiled in, TZ_VARIANTS is the list); honest demo: a hand-rolled inventory slice
fn main() {
    let zones = ["UTC", "Asia/Shanghai", "Europe/London", "America/New_York"];
    println!("{}", zones.contains(&"UTC"));
    println!("{}", zones.len() > 3); // derived fact scaled to the demo inventory
    println!("{}", zones.contains(&"Asia/Shanghai"));
}
Output
true
true
true

TypeScript v26.13.1

v26.13.1
// Intl.supportedValuesOf("timeZone"): the inventory JS engines ship (ES2022)
// note: aliases like "UTC" are not listed - canonical zone ids only
const zones: string[] = Intl.supportedValuesOf("timeZone");
console.log(zones.includes("Asia/Shanghai"));
console.log(zones.length > 100); // derived fact, machine-independent
Output
true
true

Language differences

Inventory vs setter: timezone_identifiers_list is the "look at the goods" side — it returns every IANA id the environment offers, completing the chain with the existing date_timezone_set_get entry ("then set", attaching the zone to a DateTime instance); this entry's deterministic assertions use derived facts: the inventory contains "UTC", its size exceeds 100, the CN group sorted starts at "Asia/Shanghai", and the alias is strictly equal to DateTimeZone::listIdentifiers() — the exact count floats with tzdata versions and is never asserted.

PHP: timezone_identifiers_list() is the procedural alias of DateTimeZone::listIdentifiers() (since 5.2); DateTimeZone::PER_COUNTRY plus a country code (e.g. "CN") filters by country; return order is unspecified — sort before presenting.

Python: zoneinfo.available_timezones() (PEP 615, 3.9+) is the 1:1 analog, returning a set; data comes from the tzdata package or the system zoneinfo.

Go: std has no list API — time.LoadLocation resolves ids one at a time, and listing tools are third-party; import _ "time/tzdata" embeds the IANA data into the binary (solving thin containers without a system tzdata).

Java: ZoneId.getAvailableZoneIds() is the most direct analog, backed by the JDK's bundled tzdb shipped with the JVM.

C#: TimeZoneInfo.GetSystemTimeZones() reads the OS tzdata (a read-only collection, sorted by Id); on macOS "UTC" may appear as "Etc/UTC", so the assertion is a derived Contains.

JavaScript/TypeScript: Intl.supportedValuesOf("timeZone") (ES2022) returns the engine's built-in inventory — note CLDR canonicalization strips aliases like "UTC" and lists canonical ids only, hence the "Asia/Shanghai" assertion.

C/C++: no list API — the inventory IS the zoneinfo directory on the filesystem (this entry walks it with opendir/dirent and std::filesystem); C++20 std::chrono::tzdb_list is the standard answer but this toolchain's clang libc++ does not enable it (GCC's libstdc++ does). Windows has no system tzdata, so the directory walk does not apply — embed the data in real deployments.

Rust: std has no timezone library; the chrono-tz crate compiles IANA data into the binary and exposes the TZ_VARIANTS constant (the inventory analog); the example follows the honest strategy with a hand-rolled slice carrying the same derived assertions.