// Use system locale
$locale = locale_get_default(); // same effect as setlocale(LC_TIME, "")
// Current timestamp
$now = time();
// Short date
$short = new IntlDateFormatter(
$locale,
IntlDateFormatter::SHORT,
IntlDateFormatter::NONE
);
// Long date
$long = new IntlDateFormatter(
$locale,
IntlDateFormatter::FULL,
IntlDateFormatter::NONE
);
// Time
$timeFmt = new IntlDateFormatter(
$locale,
IntlDateFormatter::NONE,
IntlDateFormatter::MEDIUM
);
// Weekday name
$weekday = new IntlDateFormatter(
$locale,
IntlDateFormatter::FULL,
IntlDateFormatter::NONE,
null,
null,
"EEEE"
);
// Month name
$month = new IntlDateFormatter(
$locale,
IntlDateFormatter::FULL,
IntlDateFormatter::NONE,
null,
null,
"MMMM"
);
echo "--- Using system locale ($locale) ---\n";
echo "Short date : " . $short->format($now) . "\n";
echo "Long date : " . $long->format($now) . "\n";
echo "Time : " . $timeFmt->format($now) . "\n";
echo "Weekday : " . $weekday->format($now) . "\n";
echo "Month name : " . $month->format($now) . "\n";
/*
run:
--- Using system locale (en_US) ---
Short date : 4/19/26
Long date : Sunday, April 19, 2026
Time : 9:25:04 AM
Weekday : Sunday
Month name : April
*/