Familiar API
Developers who have used Moment.js can adapt quickly. The chain-based API is intuitive, concise, and easy to scan inside business logic and UI code.
Day.js is a minimalist JavaScript library for parsing, validating, manipulating, and formatting dates. It offers a developer experience that feels familiar to Moment.js, while staying lighter, cleaner, immutable by default, and extensible through focused plugins.
Date handling looks simple at first, but real products quickly need formatting rules, locale support, parsing logic, timezone conversion, and readable date math. Day.js lets you start small and add only the features you actually need.
import dayjs from '@hamzaka/dayjs'
const today = dayjs()
const result = today
.startOf('month')
.add(1, 'day')
.format('YYYY-MM-DD HH:mm:ss')
// clean, readable, and chainable
console.log(result)
Day.js is not just βa tiny date library.β It is built around the date workflows that most applications use every day, while keeping the architecture modular enough to stay lean in production.
Developers who have used Moment.js can adapt quickly. The chain-based API is intuitive, concise, and easy to scan inside business logic and UI code.
Most operations return a new instance instead of mutating the original date object. That makes state handling more predictable and helps reduce side effects in complex applications.
Day.js supports locale-aware formatting and human-readable date output. You can load only the locales your project needs instead of carrying unnecessary language data.
Most date libraries are used for a similar set of tasks: parsing input, formatting output, comparing values, adding and subtracting time, and aligning dates to boundaries such as the start of a month or week. Day.js provides these tasks through a consistent API.
import dayjs from '@hamzaka/dayjs'
// parse
const d1 = dayjs('2026-04-02')
// format
console.log(d1.format('YYYY MMM DD'))
// manipulate
const d2 = d1.add(7, 'day').subtract(2, 'hour')
// compare
console.log(d2.isAfter(d1))
// boundary helpers
console.log(d1.startOf('month').format('YYYY-MM-DD'))
One of Day.jsβs biggest strengths is how compact and readable the syntax feels. The examples below are meant to serve as a practical starting point for real projects.
Once installed, you can create an instance and format it immediately. That is enough to power many UI date displays.
npm install @hamzaka/dayjs
import dayjs from '@hamzaka/dayjs'
console.log(dayjs().format())
If input strings follow a known format, the CustomParseFormat plugin makes it easier to parse them in a controlled way.
import dayjs from '@hamzaka/dayjs'
import customParseFormat from '@hamzaka/dayjs/plugin/customParseFormat'
dayjs.extend(customParseFormat)
const value = dayjs('12-25-1995', 'MM-DD-YYYY')
console.log(value.format('YYYY/MM/DD'))
With the UTC and Timezone plugins, it becomes much easier to manage multi-region products and convert server times for end users.
import dayjs from '@hamzaka/dayjs'
import utc from '@hamzaka/dayjs/plugin/utc'
import timezone from '@hamzaka/dayjs/plugin/timezone'
dayjs.extend(utc)
dayjs.extend(timezone)
const toronto = dayjs.tz('2013-11-18 11:55:20', 'America/Toronto')
console.log(toronto.format())
Day.js does not try to put every feature into the core package. Instead, it uses plugins to add capabilities when your application needs them. This makes it easier to stay efficient while still supporting advanced use cases.
Use richer formatting tokens when the built-in options are not enough for your design or reporting requirements.
Great for activity feeds, messages, notifications, and any UI that needs phrases like β5 minutes ago.β
Essential when backend systems store UTC values and your interface needs to present the correct local time.
In many projects, yes. It keeps a familiar developer experience while offering a lighter footprint and an immutable design.
No. The core stays intentionally small, and features such as custom parsing, UTC, and timezone support are added through plugins.
Yes. Day.js works well in TypeScript environments and is commonly used in modern frontend stacks.