dayjs vs moment vs luxon vs js-joda
JavaScript Date and Time Manipulation Libraries
dayjsmomentluxonjs-jodaSimilar Packages:
JavaScript Date and Time Manipulation Libraries

JavaScript date and time manipulation libraries simplify working with dates, times, timezones, and durations in web applications. These libraries provide APIs for parsing, formatting, validating, and manipulating temporal data in a more developer-friendly and robust way than the native JavaScript Date object. moment was historically the most popular library but is now in maintenance mode. dayjs is a lightweight, modern alternative with a Moment-like API but significantly smaller bundle size. luxon is built on the modern Intl API and emphasizes immutability and timezone support using the system's locale and timezone data. js-joda is a port of the Java Time API (JSR-310), offering a comprehensive, immutable, and object-oriented approach to date-time handling, ideal for complex date logic and compatibility with Java backend systems.

Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
dayjs30,531,85148,384679 kB1,16417 days agoMIT
moment25,800,38248,0904.35 MB3032 years agoMIT
luxon17,050,41816,2304.59 MB1812 months agoMIT
js-joda33,5501,652-216 years agoBSD-3-Clause
Feature Comparison: dayjs vs moment vs luxon vs js-joda

API Design & Mutability

  • dayjs:

    dayjs uses an immutable API with a fluent chainable syntax similar to Moment.js, making it intuitive for developers familiar with Moment while avoiding unintended side effects.

  • moment:

    moment uses a mutable API, which can lead to unexpected side effects. While its chainable syntax is familiar, mutability is considered a design flaw in modern date libraries.

  • luxon:

    luxon is fully immutable and leverages a modern, functional style. Its API is clean but differs significantly from Moment, requiring a learning curve for developers accustomed to older libraries.

  • js-joda:

    js-joda provides a strictly immutable API with a rich object model (e.g., LocalDate, ZonedDateTime), inspired by Java’s modern time API, ensuring thread safety and predictable behavior.

Bundle Size

  • dayjs:

    dayjs is extremely lightweight (~2 KB minified + gzipped). Additional features like timezones or locales are available as plugins, keeping the core minimal.

  • moment:

    moment is large (~65 KB minified + gzipped) and includes all locales by default, making it unsuitable for performance-sensitive applications.

  • luxon:

    luxon is around ~10–15 KB gzipped and has no dependencies. It relies on the browser’s Intl API, so polyfills may be needed in older environments.

  • js-joda:

    js-joda is moderately sized (~40 KB gzipped) due to its comprehensive API surface and Java-like architecture, which may be heavier than needed for simple use cases.

Timezone Support

  • dayjs:

    dayjs supports timezones via an optional plugin (timezone), requiring manual inclusion of timezone data (e.g., from Intl or custom offsets).

  • moment:

    moment supports timezones via the separate moment-timezone package, which bundles large timezone data and increases application size substantially.

  • luxon:

    luxon has excellent built-in timezone support using the browser’s Intl API, including named timezones (e.g., 'America/New_York') without extra packages.

  • js-joda:

    js-joda supports timezones through its @js-joda/timezone package, which includes IANA timezone data. This adds significant size but enables full timezone-aware operations.

Internationalization (i18n)

  • dayjs:

    dayjs supports i18n through locale plugins. Only the required locales need to be imported, keeping bundle size efficient.

  • moment:

    moment includes all locales by default unless manually tree-shaken, leading to bloat. Locale switching is supported but adds maintenance overhead.

  • luxon:

    luxon leverages the browser’s Intl API for formatting in any locale supported by the user’s environment—no extra locale files needed.

  • js-joda:

    js-joda requires additional packages like @js-joda/locale for i18n formatting, which adds complexity and size.

Code Examples

  • dayjs:

    dayjs example for parsing and formatting

    const dayjs = require('dayjs');
    const date = dayjs('2025-11-04');
    console.log(date.format('YYYY-MM-DD')); // '2025-11-04'
    
  • moment:

    moment example (legacy)

    const moment = require('moment');
    const date = moment('2025-11-04');
    console.log(date.format('YYYY-MM-DD')); // '2025-11-04'
    
  • luxon:

    luxon example for timezone-aware formatting

    const { DateTime } = require('luxon');
    const dt = DateTime.fromISO('2025-11-04T12:00:00', { zone: 'America/New_York' });
    console.log(dt.toFormat('yyyy-MM-dd HH:mm ZZZZ'));
    
  • js-joda:

    js-joda example for creating a date and adding days

    const { LocalDate } = require('@js-joda/core');
    const date = LocalDate.parse('2025-11-04');
    const future = date.plusDays(7);
    console.log(future.toString()); // '2025-11-11'
    
How to Choose: dayjs vs moment vs luxon vs js-joda
  • dayjs:

    Choose dayjs if you need a small, fast, and modern date library with a Moment.js-compatible API. It’s ideal for frontend applications where bundle size matters and basic to intermediate date operations are required.

  • moment:

    Choose moment only for maintaining legacy codebases. New projects should avoid it due to its large size, mutability, and lack of active development.

  • luxon:

    Choose luxon if you need strong internationalization (i18n) and timezone support without external dependencies, leveraging the browser’s built-in Intl APIs for formatting and parsing.

  • js-joda:

    Choose js-joda if you require a robust, immutable date-time API modeled after Java’s Time API, especially in applications with complex date calculations or when aligning with Java backend logic.

README for 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 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]

                                                               Instagram Story Viewer          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.