格式
由 Go 基于 Unicode CLDR 渲染的区域感知格式,选项和输出与 JavaScript 的 Intl 一致。可在页面底部切换语言。
简体中文
CLDR 48 (cldr-json 48.2.1)
zh-Hanszh-Hans-CN方向 ltr数字 latn原生 hanidecCNY时区 America/New_York
数字
Intl.NumberFormat 选项,由服务器根据 CLDR 数据格式化。
| 输入 | 选项 | 结果 |
|---|---|---|
1234567.891 | {} | 1,234,567.891 |
-0.256 | {style: "percent", maximumFractionDigits: 1} | -25.6% |
1234567 | {notation: "compact"} | 123万 |
1234567 | {notation: "compact", compactDisplay: "long"} | 123万 |
0.000123 | {notation: "scientific"} | 1.23E-4 |
1234567.891 | {notation: "engineering"} | 1.235E6 |
1234.5678 | {maximumSignificantDigits: 3} | 1,230 |
2.5 | {maximumFractionDigits: 0, roundingMode: "halfEven"} | 2 |
0 | {signDisplay: "exceptZero"} | 0 |
42 | {signDisplay: "always"} | +42 |
7 | {minimumIntegerDigits: 3} | 007 |
1234567.891 | {numberingSystem: "hanidec"} | 一,二三四,五六七.八九一 |
货币
金额精确无误(以整数最小单位表示),并采用 CLDR 的货币小数位数。本地货币:CNY。
| 输入 | 选项 | 结果 |
|---|---|---|
1234.5 CNY | {style: "currency", currency: "CNY"} | ¥1,234.50 |
-1234.5 CNY | {…, currencySign: "accounting"} | (¥1,234.50) |
1 CNY | {…, currencyDisplay: "name"} | 1.00人民币 |
1234.5 CNY | {…, currencyDisplay: "name"} | 1,234.50人民币 |
1234.5 CNY | {…, currencyDisplay: "code"} | CNY 1,234.50 |
1234567 CNY | {…, notation: "compact"} | ¥123万 |
9.99 USD | {style: "currency", currency: "USD", currencyDisplay: "narrowSymbol"} | $9.99 |
1234.5 JPY | {style: "currency", currency: "JPY"} | JP¥1,235 |
1234.5 BHD | {style: "currency", currency: "BHD"} | BHD 1,234.500 |
日期和时间
Intl.DateTimeFormat:CLDR 样式、骨架、时段、纪元和小时制,全部针对第一列中的时刻,并按你的时区显示。
| 输入 | 选项 | 结果 |
|---|---|---|
2026-07-04T15:30:45.123Z | {dateStyle: "full", timeZone: "America/New_York"} | 2026年7月4日星期六 |
2026-07-04T15:30:45.123Z | {dateStyle: "long", timeStyle: "short", timeZone: "America/New_York"} | 2026年7月4日 11:30 |
2026-07-04T15:30:45.123Z | {dateStyle: "medium", timeStyle: "medium", timeZone: "America/New_York"} | 2026年7月4日 11:30:45 |
2026-07-04T15:30:45.123Z | {dateStyle: "short", timeStyle: "full", timeZone: "America/New_York"} | 2026/7/4 北美东部夏令时间 11:30:45 |
2026-07-04T15:30:45.123Z | {weekday: "long", month: "long", day: "numeric", timeZone: "America/New_York"} | 7月4日星期六 |
2026-07-04T15:30:45.123Z | {year: "numeric", month: "short", timeZone: "America/New_York"} | 2026年7月 |
2026-07-04T15:30:45.123Z | {hour: "numeric", minute: "2-digit", hour12: true, timeZone: "America/New_York"} | 上午11:30 |
2026-07-04T15:30:45.123Z | {hour: "numeric", minute: "2-digit", hourCycle: "h23", timeZone: "America/New_York"} | 11:30 |
2026-07-04T15:30:45.123Z | {dayPeriod: "long", hour: "numeric", timeZone: "America/New_York"} | 11时 |
2026-07-04T15:30:45.123Z | {era: "long", year: "numeric", timeZone: "America/New_York"} | 公元2026年 |
2026-07-04T15:30:45.123Z | {minute: "2-digit", second: "2-digit", fractionalSecondDigits: 3, timeZone: "America/New_York"} | 30:45.123 |
2026-07-04T15:30:45.123Z | {dateStyle: "medium", timeZone: "America/New_York", numberingSystem: "hanidec"} | 二〇二六年七月四日 |
时区
同一时刻在其他时区中的显示,附带 CLDR 时区名称:特定、通用、地点和偏移量。
| 输入 | 选项 | 结果 |
|---|---|---|
America/New_York | {hour: "numeric", minute: "2-digit", timeZoneName: "long"} | 北美东部夏令时间 11:30 |
Asia/Tokyo | {hour: "numeric", minute: "2-digit", timeZoneName: "short"} | GMT+9 00:30 |
America/New_York | {hour: "numeric", minute: "2-digit", timeZoneName: "longGeneric"} | 北美东部时间 11:30 |
America/Los_Angeles | {hour: "numeric", minute: "2-digit", timeZoneName: "shortGeneric"} | Los Angeles时间 08:30 |
Asia/Kolkata | {hour: "numeric", minute: "2-digit", timeZoneName: "shortOffset"} | GMT+5:30 21:00 |
Australia/Lord_Howe | {hour: "numeric", minute: "2-digit", timeZoneName: "longOffset"} | GMT+10:30 02:00 |
Europe/London | {hour: "numeric", minute: "2-digit", timeZoneName: "long"} | 英国夏令时间 16:30 |
Pacific/Chatham | {hour: "numeric", minute: "2-digit", timeZoneName: "long"} | 查塔姆标准时间 04:15 |
日期范围
Intl.DateTimeFormat formatRange:CLDR 区间格式只显示一次相同的字段,仅重复不同的字段。
| 输入 | 选项 | 结果 |
|---|---|---|
2026-07-04T15:30:45.123Z – 2026-07-04T17:00:45.123Z | {hour: "numeric", minute: "2-digit", timeZone: "America/New_York"} | 11:30–13:00 |
2026-07-04T15:30:45.123Z – 2026-07-04T17:00:45.123Z | {dateStyle: "long", timeStyle: "short", timeZone: "America/New_York"} | 2026/7/4 11:30–13:00 |
2026-07-04T15:30:45.123Z – 2026-07-09T15:30:45.123Z | {dateStyle: "medium", timeZone: "America/New_York"} | 2026/7/4 – 2026/7/9 |
2026-07-04T15:30:45.123Z – 2026-08-20T15:30:45.123Z | {month: "long", day: "numeric", timeZone: "America/New_York"} | 7/4 – 8/20 |
2026-07-04T15:30:45.123Z – 2027-01-15T15:30:45.123Z | {year: "numeric", month: "short", day: "numeric", timeZone: "America/New_York"} | 2026/7/4 – 2027/1/15 |
单位
Intl.NumberFormat style "unit":带复数形式的 CLDR 单位模式、复合单位(每…)和紧凑数字。
| 输入 | 选项 | 结果 |
|---|---|---|
1 kilometer | {style: "unit", unit: "kilometer", unitDisplay: "long"} | 1公里 |
2.5 kilometer | {…, unitDisplay: "long"} | 2.5公里 |
88 kilometer-per-hour | {unit: "kilometer-per-hour"} | 88 km/h |
21.5 celsius | {unit: "celsius"} | 21.5°C |
512 megabyte | {unit: "megabyte", unitDisplay: "narrow"} | 512 MB |
3 liter-per-kilometer | {unit: "liter-per-kilometer", unitDisplay: "long"} | 每公里3升 |
1234567 meter | {unit: "meter", notation: "compact", unitDisplay: "long"} | 123万米 |
相对时间
Intl.RelativeTimeFormat:带复数规则的 CLDR dateFields;numeric "auto" 会使用“昨天”之类的词。
| 输入 | 选项 | 结果 |
|---|---|---|
-1 day | {numeric: "auto"} | 昨天 |
2 day | {numeric: "auto"} | 后天 |
-3 hour | {} | 3小时前 |
5 minute | {style: "short"} | 5分钟后 |
-1.5 week | {style: "narrow"} | 1.5周前 |
1 quarter | {numeric: "auto"} | 下季度 |
-10 year | {} | 10年前 |
列表
Intl.ListFormat:CLDR 列表模式,以及 ICU 在代码中应用的西班牙语和希伯来语规则。
| 输入 | 选项 | 结果 |
|---|---|---|
简体中文 · Go · htmx | {type: "conjunction"} | 简体中文、Go和htmx |
简体中文 · Go · htmx | {type: "disjunction"} | 简体中文、Go或htmx |
简体中文 · Go · htmx · Cloudflare | {type: "unit", style: "narrow"} | 简体中文GohtmxCloudflare |
简体中文 · Go | {style: "short"} | 简体中文和Go |
时长
Intl.DurationFormat,数字单位采用 Chrome 的输出。
| 输入 | 选项 | 结果 |
|---|---|---|
1d 2h 5m 30.25s | {} | 1天2小时5分钟30秒250毫秒 |
1d 2h 5m 30.25s | {style: "long"} | 1天2小时5分钟30秒钟250毫秒 |
1d 2h 5m 30.25s | {style: "narrow"} | 1天2小时5分钟30秒250ms |
1d 2h 5m 30.25s | {style: "digital", fractionalDigits: 2} | 1天2:05:30.25 |
复数规则
CLDR 复数类别,以及选中各类别的前几个数字。
| 输入 | 选项 | 结果 |
|---|---|---|
cardinal · other | {type: "cardinal"} | 0, 1, 2, 3, 4, 0.0 |
ordinal · other | {type: "ordinal"} | 0, 1, 2, 3, 4 |
周
Intl.Locale getWeekInfo:该语言区域所在地区的 CLDR weekData(1 = 星期一 … 7 = 星期日)。
| 输入 | 选项 | 结果 |
|---|---|---|
firstDay | getWeekInfo() | 1 |
weekend | getWeekInfo() | 6, 7 |
minimalDays | CLDR weekData | 1 |