# @financial-times/ft-date-format 中文文档

规范地址：https://npmcn.com/package/%40financial-times/ft-date-format/

版本：4\.0\.0
npm 元数据更新时间：2026-10-06T13:38:36.118Z
中文译文更新时间：2026-11-14T18:16:27.667Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40financial-times/ft-date-format
原文对照：https://npmcn.com/package/%40financial-times/ft-date-format/?lang=original
项目主页：https://github.com/Financial-Times/ft-date-format#readme
源码仓库：https://github.com/Financial-Times/ft-date-format

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：42.8 kB，15 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：0 个
- 首次发布：2019-03-01T10:41:18.233Z
- 最新版本发布：2025-05-21T15:39:51.050Z
- 近 30 天下载量：6413（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：11（近 12 个月 0 个）

## 中文简介

Financial-Times客户产品格式化和更新日期的工具

## 安装

```sh
npm install @financial-times/ft-date-format
```

也可以使用：`pnpm add @financial-times/ft-date-format`、`yarn add @financial-times/ft-date-format`、`bun add @financial-times/ft-date-format`

## README

# ft- 日期格式

ft-date-format提供javascript 工具,用于FT样式格式化和更新日期.

-   [使用量](https://npmcn.com/package/%40financial-times/ft-date-format/#readme-usage)
    -   [Java 脚本](https://npmcn.com/package/%40financial-times/ft-date-format/#readme-javascript)
-   [移徙指南](https://npmcn.com/package/%40financial-times/ft-date-format/#readme-migration-guide)
-   [联系人](https://npmcn.com/package/%40financial-times/ft-date-format/#readme-contact)
-   [许可证](https://npmcn.com/package/%40financial-times/ft-date-format/#readme-licence)

## 使用量

### Java 脚本

#### ft-date-format#format(日期,tpl) 互联网档案馆的存檔,存档日期2013-12-21

返回一个格式化为字符串的日期

-   `date`: 一个Javascript `Date` 对象或传递到 `Date` 构造器
-   `tpl`: 指定输出日期的格式的字符串 :
    -   `'datetime'`:格式化标准FT长格式中的日期,包括时间. 举个例子. `May 15, 2014 8:10 am`
    -   `'date'`:格式化标准FT长格式中的日期. 举个例子. `May 15, 2014`
    -   使用其他字符串 [广泛公约](http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) 时间/日期的占位符,将取而代之的是从提供的日期提取的数值。 见 `./main.js` 用于更新所支持格式的清单。 避免例如: `mm` 内 `common` 以双回击取代月份前缀 `co\\mmon` 即说. _在大多数情况下,不应使用自定义的日期格式,而应采用标准的FT日期和日期格式_

#### ft-date-format#timeAgo(日期)

返回自给定日期以来的相对时间,格式化为人类可读字符串,例如. `13 minutes ago`。 。 。 .

#### ft-date-format#ftTime(日期)

按照FT日期格式惯例,返回某一日期的相对时间或时间戳.

-   `date`: 一个Javascript `Date` 对象或传递到 `Date` 构造器

#### ft-date-format# as Today 或昨天 Or nothing(日期)

回返 `'yesterday'`, (中文(简体) ), `'today'` 或者说 `''` 在一个特定的日期。 您可以请求此格式用于 `ft-date-format` 添加组件 `data-ft-date-format-format="today-or-yesterday-or-nothing"`。 。 。 .

-   `date`: 一个Javascript `Date` 对象或传递到 `Date` 构造器

* * *

## 移徙指南

| 状态 | 主要版本 | 最后一个小版本 | 移徙指南 |
| :-: | :-: | :-: | :-: |
| 活动 | 2个 | 不详 | [迁移到 v2](https://npmcn.com/package/%40financial-times/ft-date-format/MIGRATION.md#migrating-from-v1-to-v2) |
| 维护 | 1个 | 1.0.5 (简体中文) | \- 说吧 |

* * *

## 联系人

如果您有任何问题、评论或需要帮助,请使用ft-date-format [提出问题](https://github.com/Financial-Times/ft-date-format/issues)访问 [{\\fn黑体\\fs20\\shad2\\2ah82\\3ah20\\4ah33\\fscx95\\3ch592001\\be1}#毛发折射](https://financialtimes.slack.com/messages/ft-origami/) 或电子邮件 [折纸支持](mailto:origami-support@ft.com)。 。 。 .

* * *

## 许可证

本软件由金融时报根据以下规定出版: [麻省理工学院许可证](http://opensource.org/licenses/MIT)。 。 。 .

## 常见问题

### @financial-times/ft-date-format 是什么？

Financial-Times客户产品格式化和更新日期的工具

### 如何安装 @financial-times/ft-date-format？

在项目目录运行 npm install @financial-times/ft-date-format，或使用 pnpm add / yarn add / bun add。

### @financial-times/ft-date-format 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/financial-times\_\_ft-date-format 是否存在。

### @financial-times/ft-date-format 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @financial-times/ft-date-format 可以商用吗？

@financial-times/ft-date-format 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @financial-times/ft-date-format 的下载量有多少？

根据 npm 官方下载统计，@financial-times/ft-date-format 在 2026/10/15 – 2026/11/13 这 30 天内被下载 6,413 次，日均约 214 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @financial-times/ft-date-format 还在维护吗？

最新版本 4\.0\.0 发布于 2025/05/21（1\.5 年前）；至今共发布 11 个版本，其中过去 12 个月发布了 0 个；首次发布于 2019/03/01。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

