IntlDateFormatter

IntlDateFormatter::create(?string $locale, int $dateType = IntlDateFormatter::FULL, int $timeType = IntlDateFormatter::FULL, IntlTimeZone|DateTimeZone|string|null $timezone = null, IntlCalendar|int|null $calendar = null, ?string $pattern = null): ?IntlDateFormatter

ICU's date-formatting binding for PHP: locale plus a canned style (SHORT/LONG/FULL) or an explicit pattern decides the output shape, and it can parse back to a timestamp. Sibling of JS Intl.DateTimeFormat and Java DateTimeFormatter.ofLocalizedDate. The example pins a UTC timestamp and uses explicit patterns to sidestep ICU version drift.

C C23

C23
#include <stdio.h>
#include <time.h>

int main(void) {
    /* the C standard library has no canned locale styles: strftime takes a manual pattern */
    time_t ts = (time_t)1795262400; /* 2026-11-21 12:00 UTC */
    struct tm utc = *gmtime(&ts);
    char buf[40];
    strftime(buf, sizeof buf, "%m/%d/%Y", &utc);
    printf("%s\n", buf);
    strftime(buf, sizeof buf, "%Y-%m-%d %H:%M", &utc);
    printf("%s\n", buf);
    return 0;
}
Output
11/21/2026
2026-11-21 12:00

C++ C++26

C++26
#include <cstdio>
#include <ctime>

int main() {
    // same as C: strftime with manual patterns; iostream needs a locale imbued for styles
    std::time_t ts = 1795262400; // 2026-11-21 12:00 UTC
    std::tm utc = *std::gmtime(&ts);
    char buf[40];
    std::strftime(buf, sizeof buf, "%m/%d/%Y", &utc);
    std::printf("%s\n", buf);
    std::strftime(buf, sizeof buf, "%Y-%m-%d %H:%M", &utc);
    std::printf("%s\n", buf);
    return 0;
}
Output
11/21/2026
2026-11-21 12:00

C# v11.0.100

v11.0.100
// CultureInfo drives the standard date patterns; "d"/"D" are the short/long patterns
using System.Globalization;

var ts = DateTimeOffset.FromUnixTimeSeconds(1795262400L).UtcDateTime; // 2026-11-21 12:00 UTC
Console.WriteLine(ts.ToString("d", CultureInfo.GetCultureInfo("en-US")));
Console.WriteLine(ts.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture));
Output
11/21/2026
2026-11-21 12:00

Go v1.27.4

v1.27.4
package main

import (
	"fmt"
	"time"
)

func main() {
	ts := time.Unix(1795262400, 0).UTC() // 2026-11-21 12:00 UTC
	// layout strings are explicit patterns; std has no locale-aware styles
	fmt.Println(ts.Format("01/02/2006"))
	fmt.Println(ts.Format("2006-01-02 15:04"))
	// localized styles live in golang.org/x/text (see notes)
}
Output
11/21/2026
2026-11-21 12:00

Java v27.0.1

v27.0.1
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Locale;

public class Main {
    public static void main(String[] args) {
        Instant ts = Instant.ofEpochSecond(1795262400L); // 2026-11-21 12:00 UTC
        // the JDK ships its own locale data (not ICU): ofLocalizedDate picks a locale pattern
        System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)
                .withLocale(Locale.US).withZone(ZoneOffset.UTC).format(ts));
        System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)
                .withLocale(Locale.US).withZone(ZoneOffset.UTC).format(ts));
        // an explicit pattern is version-stable, like everywhere else
        System.out.println(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
                .withZone(ZoneOffset.UTC).format(ts));
    }
}
Output
11/21/26
Nov 21, 2026
2026-11-21 12:00

JavaScript v26.13.1

v26.13.1
const ts = 1795262400; // 2026-11-21 12:00 UTC
// Intl.DateTimeFormat is the same ICU-backed family, locale passed per call
const opts = { timeZone: 'UTC', year: 'numeric', month: '2-digit', day: '2-digit' };
console.log(new Intl.DateTimeFormat('en-US', opts).format(new Date(ts * 1000)));
console.log(new Intl.DateTimeFormat('en-GB', opts).format(new Date(ts * 1000)));
Output
11/21/2026
21/11/2026

PHP v8.6.0

v8.6.0
// IntlDateFormatter is PHP's binding to ICU: locale + style/pattern decide the shape
$fmt = new IntlDateFormatter('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'UTC');
$fmt->setPattern('MM/dd/yyyy'); // explicit pattern: identical on every ICU version
echo $fmt->format(1795262400), "\n"; // 2026-11-21 12:00 UTC
$fmt->setPattern('yyyy-MM-dd HH:mm');
echo $fmt->format(1795262400), "\n";
Output
11/21/2026
2026-11-21 12:00

Python v3.15.2

v3.15.2
from datetime import datetime, timezone

ts = datetime.fromtimestamp(1795262400, tz=timezone.utc)  # 2026-11-21 12:00 UTC
# stdlib strftime: manual patterns only (locale-aware %x needs setlocale + OS locales)
print(ts.strftime('%m/%d/%Y'))
print(ts.strftime('%Y-%m-%d %H:%M'))
# real locale styles come from the third-party Babel package (see notes)
Output
11/21/2026
2026-11-21 12:00

Rust v1.99.1

v1.99.1
use chrono::{TimeZone, Utc};

fn main() {
    // chrono is the de-facto date crate (cargo); formatting uses explicit patterns
    let ts = Utc.timestamp_opt(1795262400, 0).unwrap(); // 2026-11-21 12:00 UTC
    println!("{}", ts.format("%m/%d/%Y"));
    println!("{}", ts.format("%Y-%m-%d %H:%M"));
}
Output
11/21/2026
2026-11-21 12:00

TypeScript v26.13.1

v26.13.1
const ts: number = 1795262400; // 2026-11-21 12:00 UTC
// Intl.DateTimeFormat is the same ICU-backed family, locale passed per call
const opts: Intl.DateTimeFormatOptions = { timeZone: 'UTC', year: 'numeric', month: '2-digit', day: '2-digit' };
console.log(new Intl.DateTimeFormat('en-US', opts).format(new Date(ts * 1000)));
console.log(new Intl.DateTimeFormat('en-GB', opts).format(new Date(ts * 1000)));
Output
11/21/2026
21/11/2026

Language differences

PHP: IntlDateFormatter is PHP's binding of ICU date formatting (intl extension). Constructor = locale + dateType/timeType (NONE/SHORT/MEDIUM/LONG/FULL, plus RELATIVE_* since 8.0) + timezone + calendar + optional pattern; format() accepts timestamps/DateTime/arrays, with a reversible parse(). Key decision: the example deliberately uses setPattern('MM/dd/yyyy') instead of the SHORT style — canned styles map to locale patterns that drift with CLDR/ICU versions (on this machine's ICU 79, en_US SHORT changed from "11/21/2026" to a two-digit year "11/21/26"; JS and Java show the same phenomenon), while an explicit pattern is fixed character-by-character and identical on every ICU version. ICU-version sensitivity analysis: only long text with ordinals or period names (e.g. "Nov 21, 2026", weekday names) and short-year styles are sensitive; pure numeric patterns (MM/dd/yyyy, yyyy-MM-dd HH:mm) are byte-stable across ICU versions. Cross-check: in this entry's ten outputs, Java SHORT gives "11/21/26" (the JDK ships its own data — the two-digit year happens there too, independent of ICU).

C/C++: the standard library has no locale-styled date formatting; strftime takes manual patterns only. Localized text needs setlocale(LC_TIME) plus OS-installed locales — poor portability, so the example sticks to explicit patterns.

C#: ToString("d", culture) uses the culture's short pattern (.NET built-in data; en-US is a four-digit year "11/21/2026"); InvariantCulture + an explicit pattern is the most stable form.

Java: DateTimeFormatter.ofLocalizedDate(style) uses the JDK's own locale data (not ICU, not the OS); the withLocale().withZone() chain is the parameterised school — read it against the ICU family.

JS/TS: Intl.DateTimeFormat(locale, opts) is the sibling native API (ICU built into V8/browsers); the example uses explicit numeric fields rather than dateStyle:'short' for the same reason as PHP — the short style changes with the ICU version (Node 26's en-US short style is already "11/21/26").

Python: the stdlib has only strftime (locale-aware %x/%c need setlocale + OS locales — not portable); ICU-level styles live in the third-party Babel package (format_date(ts, locale='en_US')).

Go: time.Format layout strings are fully explicit; localized styles live in golang.org/x/text (message.NewPrinter(locale)).

Rust: the chrono crate (validator cargo mode) format("%m/%d/%Y") is strftime's family; ICU-level formatting is in the icu/icu_datetime crates.

Bottom line: pin explicit pattern + fixed timezone for cross-version stability; accept ICU/CLDR upgrade nudges if you want "the most idiomatic local style" (the style tables are documented in the ICU User Guide's Date/Time Format Syntax).