# @basemachina/dayjs 中文文档

规范地址：https://npmcn.com/package/%40basemachina/dayjs/

版本：1\.11\.4
npm 元数据更新时间：2026-10-28T08:03:25.478Z
中文译文更新时间：2026-11-07T17:43:52.778Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40basemachina/dayjs
原文对照：https://npmcn.com/package/%40basemachina/dayjs/?lang=original
项目主页：https://day.js.org/
源码仓库：https://github.com/basemachina/dayjs

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

- 包体积（解压后）：375 kB，227 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2024-10-24T00:50:39.140Z
- 最新版本发布：2024-10-25T08:17:32.333Z
- 近 30 天下载量：5461（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一二一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一.

## 安装

```sh
npm install @basemachina/dayjs
```

也可以使用：`pnpm add @basemachina/dayjs`、`yarn add @basemachina/dayjs`、`bun add @basemachina/dayjs`

## README

# 日记

此寄存器为 [亚姆昆/ 天js](https://github.com/iamkun/dayjs)。 。 。 .

以下是已作的主要修改.

## 变动

-   支持将2位数的年数分析为 `YY` 格式.

## 关于Dayjs

页:1 [简体中文](https://npmcn.com/package/%40basemachina/dayjs/docs/zh-cn/README.zh-CN.md) | [日本語](https://npmcn.com/package/%40basemachina/dayjs/docs/ja/README-ja.md) | [巴西利罗港](https://npmcn.com/package/%40basemachina/dayjs/docs/pt-br/README-pt-br.md) | [한국어](https://npmcn.com/package/%40basemachina/dayjs/docs/ko/README-ko.md) | [西班牙(埃斯帕尼亚)](https://npmcn.com/package/%40basemachina/dayjs/docs/es-es/README-es-es.md) | [Русский](https://npmcn.com/package/%40basemachina/dayjs/docs/ru/README-ru.md) | [蒂尔克切](https://npmcn.com/package/%40basemachina/dayjs/docs/tr/README-tr.md) | [සිංහල](https://npmcn.com/package/%40basemachina/dayjs/docs/si/README-si.md) | [עברית](https://npmcn.com/package/%40basemachina/dayjs/docs/he/README-he.md)

[![Day.js](https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png)](https://day.js.org/)

快点 **2千贝** 以相同现代 API 的 Moment.js 替代

[![Gzip Size](https://img.shields.io/bundlephobia/minzip/dayjs?style=flat-square&color=%2345cc11)](https://bundlephobia.com/package/dayjs) [![NPM Version](https://img.shields.io/npm/v/dayjs.svg?style=flat-square&colorB=51C838)](https://www.npmjs.com/package/dayjs) [![Build Status](https://img.shields.io/github/actions/workflow/status/iamkun/dayjs/check.yml?style=flat-square)](https://github.com/iamkun/dayjs/actions/workflows/check.yml) [![Codecov](https://img.shields.io/codecov/c/github/iamkun/dayjs/master.svg?style=flat-square)](https://codecov.io/gh/iamkun/dayjs) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/iamkun/dayjs/blob/master/LICENSE)  
[![Sauce Test Status](https://user-images.githubusercontent.com/17680888/40040137-8e3323a6-584b-11e8-9dba-bbe577ee8a7b.png)](https://saucelabs.com/u/dayjs)

> Day.js是一个最小化的JavaScript库,用于剖析,验证,操控,并显示现代浏览器的日期和时间,主要具有Moment.js相容的API. 如果你使用moment.js, 你已经知道如何使用 Day.js.

```js
dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss');
```

-   & API 时尚
-   (不可改变)
-   可连锁
-   🌐 I18n 支持
-   二克b小型图书馆
-   QQ 所有支持的浏览器

* * *

## 开始

### 文档

您可以在 API 上找到更多细节 [(原始内容存档于2018-03-27). day.js.org](https://day.js.org/) 网站.

### 安装

```console
npm install @basemachina/dayjs --save
```

📚[安装指南](https://day.js.org/docs/en/installation/installation)

### API 密码

易用 Day.js APIs来解析,验证,操纵,并显示日期和时间.

```javascript
dayjs('2018-08-08') // parse

dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display

dayjs().set('month', 3).month() // get & set

dayjs().add(1, 'year') // manipulate

dayjs().isBefore(dayjs()) // query
```

📚[API 参考](https://day.js.org/docs/en/parse/parse)

### I18n 时

Day.js大力支持国际化.

但是除非你用它 否则它们都不会被包括在你的建筑里.

```javascript
import 'dayjs/locale/es' // load on demand

dayjs.locale('es') // use Spanish locale globally

dayjs('2018-05-05').locale('zh-cn').format() // use Chinese Simplified locale in a specific instance
```

📚[国际化](https://day.js.org/docs/en/i18n/i18n)

### 插件

插件是一个独立的模块,可以添加到 Day.js 来扩展功能或添加新功能.

```javascript
import advancedFormat from 'dayjs/plugin/advancedFormat' // load on demand

dayjs.extend(advancedFormat) // use plugin

dayjs().format('Q Do k kk X x') // more available formats
```

📚[插件列表](https://day.js.org/docs/en/plugin/plugin)

### 使用趋势

[![](https://user-images.githubusercontent.com/3455798/270162667-c7bd2ebe-675e-45c6-a2c9-dc67f3b65d6e.png)](https://npm-compare.com/moment,dayjs/#timeRange=THREE_YEARS)

## 发起人

通过成为赞助者来支持这一项目。 你的标志会在这里出现 链接到你的网站.

\[[通过Github成为赞助商](https://github.com/sponsors/iamkun/)\[[通过OpenCollective成为赞助商](https://opencollective.com/dayjs#sponsor)\[ . \]

 [![](https://user-images.githubusercontent.com/17680888/197092231-2367b5eb-1e43-467e-a311-23f7cd97b086.png)](https://toyokumo.co.jp/)         [![](https://avatars.githubusercontent.com/u/65305317?v=4) ](https://github.com/ken-swyfft)         [![](https://images.opencollective.com/chudovo/3c866f5/logo/256.png?height=256) ](https://chudovo.com/)         [![](https://images.opencollective.com/ratrav/8bad59c/logo/256.png?height=256) ](https://www.ratrav.com/)         [![](https://images.opencollective.com/sight-sound/54f7220/logo/256.png?height=256) ](https://opencollective.com/sight-sound)         [![](https://github.com/user-attachments/assets/b3203350-34c1-4637-b8b1-d9b8bab346d3) ](https://www.honrev.com/)         [![](https://avatars.githubusercontent.com/u/18175329?s=52&v=4) ](https://github.com/alan-eu)         [![](https://user-images.githubusercontent.com/17680888/162761622-1407a849-0c41-4591-8aa9-f98114ec2092.png) ](https://www.exoflare.com/open-source/?utm_source=dayjs&utm_campaign=open_source)         [![](https://avatars.githubusercontent.com/u/13880908?s=200&v=4) ](https://github.com/storyblok)         [![BestKru](https://avatars.githubusercontent.com/u/159320286) ](https://bestkru.com/)         [![](https://github.com/user-attachments/assets/426c3476-dc34-44d1-a904-ed58dbd20dd6) ](https://handsontable.com/docs/react-data-grid/?utm_source=Dayjs_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship)         [![Route Optimizer and Route Planner Software](https://github.com/user-attachments/assets/3fbc86c5-98a9-49c2-beae-1969026fcd76)](https://route4me.com/)

## 贡献者

这个项目的存在要归功于所有作出贡献的人.

请给我们一颗恒星 支持我们 谢谢.

感谢所有的支持者

[![](https://opencollective.com/dayjs/backer/0/avatar.svg?requireActive=false)](https://opencollective.com/dayjs/backer/0/website?requireActive=false) [![](https://opencollective.com/dayjs/backer/1/avatar.svg?requireActive=false)](https://opencollective.com/dayjs/backer/1/website?requireActive=false) [![](https://opencollective.com/dayjs/backer/2/avatar.svg?requireActive=false)](https://opencollective.com/dayjs/backer/2/website?requireActive=false) [![](https://opencollective.com/dayjs/backer/3/avatar.svg?requireActive=false)](https://opencollective.com/dayjs/backer/3/website?requireActive=false)  
[![](https://opencollective.com/dayjs/contributors.svg?width=890)](https://opencollective.com/dayjs#backers)

## 许可证

日.js根据 [MIT 许可证](https://npmcn.com/package/%40basemachina/dayjs/LICENSE)。 。 。 .

## 常见问题

### @basemachina/dayjs 是什么？

一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一二一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一\.

### 如何安装 @basemachina/dayjs？

在项目目录运行 npm install @basemachina/dayjs，或使用 pnpm add / yarn add / bun add。

### @basemachina/dayjs 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @basemachina/dayjs 支持 ESM 还是 CommonJS？

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

### @basemachina/dayjs 可以商用吗？

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

### @basemachina/dayjs 的下载量有多少？

根据 npm 官方下载统计，@basemachina/dayjs 在 2026/10/08 – 2026/11/06 这 30 天内被下载 5,461 次，日均约 182 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @basemachina/dayjs 还在维护吗？

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

