Format and display dates in web apps without bloating your bundle size.
Parse user-submitted date strings and perform arithmetic like adding days or months.
Display dates in multiple languages and regional formats using built-in locale support.
Chain date operations together to calculate things like 'the start of next month' in one readable expression.
Day.js is a lightweight JavaScript library for working with dates and times. It solves a common problem in web development: JavaScript's built-in date handling is verbose and error-prone, and the long-dominant library Moment.js (which provided a much better API) became very large and heavy over the years, making it a poor choice for web pages where file size matters. Day.js provides nearly identical functionality to Moment.js but in a package that is only about 2 kilobytes when compressed, roughly 97% smaller than Moment.js. This matters for web apps because smaller libraries mean faster page loads. The library lets you parse date strings into date objects, format them for display (for example, converting a date to "2025-05-06" or "May 6th, 2025"), perform arithmetic like adding days or subtracting months, compare dates, and check whether one date is before or after another. A key design principle is immutability: when you perform an operation on a Day.js object, it returns a new object rather than modifying the original. This prevents subtle bugs where code in one place accidentally changes a date value used elsewhere. Operations are also chainable, meaning you can write compact expressions like "start of this month, plus one day, formatted as a string." Day.js supports over 100 locales for internationalization (displaying dates in different languages and formats), and its plugin system lets you add optional features, like advanced formatting, relative time ("3 hours ago"), or timezone support, only when needed, keeping the base bundle small. You would use Day.js in any JavaScript or TypeScript web or Node.js project that needs reliable date parsing and formatting. The tech stack is plain JavaScript, distributed as an npm package compatible with all modern browsers.
Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.