Reference JavaScript reference

Intl.DateTimeFormat 参考

Intl.DateTimeFormat Reference,整理语法、参数、示例、返回值和常见错误,适合快速查询 JavaScript 写法。

语法

js
const formatter = new Intl.DateTimeFormat("zh-CN");

参数

  • locales:语言区域,例如 zh-CN。
  • options:格式化器配置,例如样式、时区、排序规则。

返回值

返回格式化器实例,可继续调用 format、compare 等方法。

示例

js
const formatter = new Intl.DateTimeFormat("zh-CN");
console.log(formatter);

常见错误

  • 不同运行环境支持的 locale 和格式化细节可能有差异。

相关内容