Huge news!Announcing our $20M Series A led by Andreessen Horowitz.Learn more
Socket
Socket
Log inDemoInstall

dayjs

Package Overview
Dependencies
0
Maintainers
1
Versions
123
Issues
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

dayjs

2KB immutable date time library alternative to Moment.js with the same modern API

    1.11.10latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
17,623,733
decreased by-13.05%

Weekly downloads

Package description

What is dayjs?

The dayjs npm package is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API. It is lightweight and offers various functionalities to handle dates and times effectively.

What are dayjs's main functionalities?

Parsing

Parse a date string into a dayjs object.

dayjs('2023-04-01')

Validation

Check if a date is valid.

dayjs('2023-04-01').isValid()

Manipulation

Manipulate the date by adding time to it.

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

Display

Display the date in a specified format.

dayjs().format('YYYY-MM-DD')

Query

Query the date to compare with another date.

dayjs().isBefore(dayjs('2023-12-31'))

Localization

Localize the date to a different language.

dayjs().locale('es').format('dddd, MMMM D YYYY')

Timezone

Handle timezone conversions.

dayjs().tz('America/New_York').format()

Other packages similar to dayjs

Changelog

Source

1.11.10 (2023-09-19)

Bug Fixes

  • Add Korean Day of Month with ordinal (#2395) (dd55ee2)
  • change back fa locale to the Gregorian calendar equivalent (#2411) (95e9458)
  • duration plugin - MILLISECONDS_A_MONTH const calculation (#2362) (f0a0b54)
  • duration plugin getter get result 0 instead of undefined (#2369) (061aa7e)
  • fix isDayjs check logic (#2383) (5f3f878)
  • fix timezone plugin to get correct locale setting (#2420) (4f45012)
  • locale: add meridiem in ar locale (#2418) (361be5c)
  • round durations to millisecond precision for ISO string (#2367) (890a17a)
  • sub-second precisions need to be rounded at the seconds field to avoid adding floats (#2377) (a9d7d03)
  • update $x logic to avoid plugin error (#2429) (2254635)
  • Update Slovenian locale for relative time (#2396) (5470a15)
  • update uzbek language translation (#2327) (0a91056)

Readme

Source

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 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

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]

                                                              

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.

Keywords

FAQs

Last updated on 19 Sep 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install
SocketSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc