← All open source projects

Day.js

iamkun/dayjs

Day.js is a small JavaScript date and time library with a Moment.js-like API and immutable objects.

Forks 2,438
Author iamkun
Language JavaScript
License MIT
Synced 2026-06-10

What it is

Day.js is a minimalist JavaScript library for date and time work. Its main idea is a familiar Moment.js-style API in a compact implementation with immutable objects and opt-in plugins. That is why teams often choose it when they want a known date API style without a heavy dependency.

The repository appeared in 2018, when the JavaScript ecosystem was actively moving away from Moment.js toward lighter solutions. Day.js does not try to be the built-in standard for every case; it handles a common task well: parse a date, modify it, format it, localize it, and do so predictably.

What is inside

Inside are the library core, plugins, locales, tests, and documentation. The base package stays small, while features such as UTC, duration, relative time, or advanced formatting are added separately. That helps control client-side bundle size.

Formatting and chained operations

This example shows why Day.js feels familiar to Moment.js users: operations can be chained, while the original object remains unchanged.

Language: JavaScript
import dayjs from "dayjs";

const invoiceDate = dayjs("2026-06-10");
const dueDate = invoiceDate.add(14, "day");

console.log(invoiceDate.format("YYYY-MM-DD"));
console.log(dueDate.format("DD MMM YYYY"));

Where it is useful

Day.js fits interfaces, forms, reports, calendars, account pages, and anywhere a date needs to be shown to a person. It is especially convenient when migrating older Moment.js code because many patterns remain recognizable.

Limitations

Dates and time are more complex than they look: time zones, calendar rules, locales, and durations quickly add nuance. Day.js handles everyday needs well, but heavy calendar logic or strict time modeling may require careful plugin setup or a different tool.