Intl.DateTimeFormat resolvedOptions Reveals Defaults
Inspect the effective timeZone, calendar, numberingSystem, and hourCycle resolved by Intl.DateTimeFormat after applying locale extension tags.
Code
const configs = [
['en-US-u-hc-h23', { dateStyle: 'short', timeStyle: 'short', timeZone: 'UTC' }],
['th-TH-u-ca-buddhist', { dateStyle: 'medium', timeZone: 'Asia/Bangkok' }],
['ar-EG-u-nu-arab', { dateStyle: 'medium', timeZone: 'Africa/Cairo' }],
];
for (const [locale, options] of configs) {
const fmt = new Intl.DateTimeFormat(locale, options);
const resolved = fmt.resolvedOptions();
console.log(
resolved.locale,
'| tz:', resolved.timeZone,
'| cal:', resolved.calendar,
'| num:', resolved.numberingSystem,
'| hc:', resolved.hourCycle ?? 'none',
);
console.log(' formatted:', fmt.format(new Date('2026-11-24T14:05:00Z')));
}Output
Captured from a sandboxed run of this snippet in the build pipeline.
en-US-u-hc-h23 | tz: UTC | cal: gregory | num: latn | hc: h23
formatted: 11/24/26, 14:05
th-TH-u-ca-buddhist | tz: Asia/Bangkok | cal: buddhist | num: latn | hc: none
formatted: 24 พ.ย. 2569
ar-EG-u-nu-arab | tz: Africa/Cairo | cal: gregory | num: arab | hc: none
formatted: ٢٤/١١/٢٠٢٦Execution path — Intl.DateTimeFormat resolvedOptions Reveals Defaults
The loop for (const [locale, options] of configs) is the only repeated construct.
Demo state sits in top-level bindings: configs.
What to watch for
- Zero-fetch snippet: every identifier resolves inside the language distribution.
Using it
Stdout messages arrive prefixed by — formatted: — when the file runs.
Key statements
const fmt = new Intl.DateTimeFormat(locale, options);
Interactive Tools for This Topic
Dotenv File ParserParse .env file content into a JSON object, handling comments, export prefixes, single quotes, and double-quoted escape sequences.INI File ParserParse INI configuration files into nested JSON with section objects, global keys, and both semicolon and hash comment support.JSON to TOML ConverterTurn a JSON object into TOML, emitting nested objects as tables and arrays of objects as array-of-tables blocks.JSON to YAML ConverterConvert JSON to readable YAML with nested block mappings, sequences, and quoting only where it is required.
FAQ
- Does the code pull in any external packages?
- No external packages are involved; every call resolves to a built-in API. Its state lives in module-level bindings: `configs`.
Report a problem with this exampleOpens a pre-filled issue on GitHub.