@basemachina/dayjs

中文文档
1.11.4发布于 2024/10/25MITTypeScriptCommonJS零依赖近 30 天下载 5461

A fork of iamkun/dayjs.

原始使用文档
文档目录12 节
  1. Changes
  2. About Dayjs
  3. Getting Started
  4. Documentation
  5. Installation
  6. API
  7. I18n
  8. Plugin
  9. Usage Trend
  10. Sponsors
  11. Contributors
  12. License

Dayjs

This repository is a fork of iamkun/dayjs.

The following are the main changes that have been made.

Changes

  • Support parsing 2-digit years with YY format.

About Dayjs

English | 简体中文 | 日本語 | Português Brasileiro | 한국어 | Español (España) | Русский | Türkçe | සිංහල | עברית

Day.js

Fast 2kB alternative to Moment.js with the same modern API

Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API. If you use Moment.js, you already know how to use Day.js.

dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss');
  • 🕒 Familiar Moment.js API & patterns
  • 💪 Immutable
  • 🔥 Chainable
  • 🌐 I18n support
  • 📦 2kb mini library
  • 👫 All browsers supported

Getting Started

Documentation

You can find more details, API, and other docs on day.js.org website.

Installation

npm install @basemachina/dayjs --save

📚Installation Guide

API

It's easy to use Day.js APIs to parse, validate, manipulate, and display dates and times.

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 Reference

I18n

Day.js has great support for internationalization.

But none of them will be included in your build unless you use it.

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

📚Internationalization

Plugin

A plugin is an independent module that can be added to Day.js to extend functionality or add new features.

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

📚Plugin List

Usage Trend

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

[Become a sponsor via Github] [Become a sponsor via OpenCollective]

                                                                                 BestKru                   Route Optimizer and Route Planner Software

Contributors

This project exists thanks to all the people who contribute.

Please give us a 💖 star 💖 to support us. Thank you.

And thank you to all our backers! 🙏


License

Day.js is licensed under a MIT License.

版本与发布记录

@basemachina/dayjs 共发布 4 个版本,首次发布于 2024/10/24;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.11.4latest2024/10/252 年前
1.11.32024/10/252 年前
1.11.22024/10/242 年前
1.11.12024/10/242 年前

关于 @basemachina/dayjs 的常见问题

@basemachina/dayjs 是什么?

A fork of iamkun/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 和提交记录判断。