dayjs README

The project's README from github.com/iamkun/dayjs. As one markdown file: README.md.

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');

Getting Started

Documentation

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

Installation

npm install 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 them.

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

Downloads

Day.js Chart

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]

                                    Sayfone Cheap international calls                   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.

dayjs (iamkun/dayjs)

Searching Database…

48.7K ·GitHub
What is this?Day.js is a minimalist JavaScript library for parsing, validating, manipulating, and displaying dates and times, built as a lightweight alternative to Moment.js.
Is this a drop-in replacement for Moment.js or something different?It's a library with a largely Moment.js-compatible API, so if you already know Moment.js you already know how to use Day.js, but it's not the same codebase.
How do I add it to a project?Install it via your package manager (e.g. npm) and import Day.js into your code; a dedicated installation guide is linked from the docs site.
Do I need any extra setup to use locales or extra features?Locales and extended features are opt-in plugins/modules that are not bundled by default, so you load only what you need to keep the footprint small.
What don't I get out of the box?The core bundle intentionally excludes i18n locales and extra functionality; you must add plugins explicitly to extend Day.js beyond its minimal core.
Does it work in all browsers, or just modern ones?Day.js is designed for modern browsers and the README states all browsers are supported.
How big is Day.js compared to Moment.js?Day.js is only about 2kB minified and gzipped, much smaller than Moment.js, while keeping a similar API.
Is Day.js mutable like some date libraries?No, Day.js objects are immutable; every manipulation returns a new instance instead of modifying the original.
Can I chain date operations?Yes, Day.js methods are chainable, so you can combine multiple manipulations in a single expression.
Which languages does Day.js support out of the box?The README itself is translated into English, Chinese, Japanese, Portuguese, Korean, Spanish, Russian, Turkish, Sinhala, and Hebrew, and Day.js ships i18n plugins for localized date formatting.
Creator
iamkun
Size
6 MB
Stars
48.7K
Age
8y
Commits · 90 Days