Luxon
Modern, immutable date library by Moment.js creator. Uses the Intl API for time zones and localization. Recommended for new projects.
Install: npm install luxon
Stars: ~14k GitHub stars
Compare and choose the best date/time library for your project. From lightweight to feature-rich solutions.
Popular libraries for handling dates and times in JavaScript applications.
Modern, immutable date library by Moment.js creator. Uses the Intl API for time zones and localization. Recommended for new projects.
Modular, functional utility library with tree-shaking support. 200+ functions for date manipulation. Consistent API design.
Minimalist library with Moment.js-compatible API. Only 2KB! Plugins extend functionality as needed.
Legacy library, now in maintenance mode. Large bundle size but comprehensive features. Consider alternatives for new projects.
Future JavaScript standard for dates and times. Currently Stage 3 proposal. Will replace Date object with modern, powerful API.
JavaScript port of Java's java.time API. Immutable, type-safe, comprehensive. Inspired by Temporal proposal.
Side-by-side feature comparison to help you choose.
| Library | Size | Immutable | Tree-shakable | Time Zones | TypeScript | Recommendation |
|---|---|---|---|---|---|---|
| Luxon | ~17KB | ✓ | ✗ | ✓✓ | ✓ | Best for time zones |
| date-fns | ~13KB* | ✓ | ✓✓ | ✓ | ✓ | Best for modern bundlers |
| Day.js | ~2KB | ✓ | ✗ | ✓ | ✓ | Best for small size |
| Moment.js | ~67KB | ✗ | ✗ | ✓ | ✓ | Legacy (migrate away) |
| js-joda | ~43KB | ✓ | ✗ | ✓ | ✓✓ | Best for type safety |
* Size varies based on which functions you import
Popular date/time libraries across different programming ecosystems.
Built-in datetime module for basic operations. python-dateutil and Arrow for extended functionality. Pendulum for human-friendly API.
datetime (built-in)
python-dateutil
Arrow
Pendulum
Modern java.time API (Java 8+) replaces legacy Date/Calendar. Immutable, comprehensive, thread-safe. Industry standard.
java.time (built-in)
LocalDate
ZonedDateTime
Joda-Time (legacy)
Built-in DateTime and DateTimeOffset. NodaTime for advanced time zone handling, inspired by Joda-Time.
DateTime (built-in)
DateTimeOffset
NodaTime
TimeZoneInfo
Built-in DateTime class with DateTimeImmutable for immutability. Carbon library provides fluent, expressive API.
DateTime (built-in)
DateTimeImmutable
Carbon
Chronos
Built-in Time, Date, and DateTime classes. ActiveSupport (Rails) adds convenience methods and time zone support.
Time (built-in)
Date
ActiveSupport::TimeWithZone
Chronic (parsing)
Built-in time package with excellent time zone support. Simple, powerful API. Duration type for time arithmetic.
time (built-in)
time.Time
time.Duration
IANA timezone support
Quick syntax comparison across popular JavaScript libraries.
// Luxon Examples
import { DateTime } from 'luxon';
// Create dates
const now = DateTime.now();
const specific = DateTime.fromISO('2024-12-31');
const fromFormat = DateTime.fromFormat('31/12/2024', 'dd/MM/yyyy');
// Format dates
now.toFormat('dd/MM/yyyy'); // 31/12/2024
now.toISO(); // 2024-12-31T23:59:59.000Z
// Time zones
now.setZone('America/New_York');
now.zoneName; // 'America/New_York'
// Manipulation
now.plus({ days: 7 });
now.minus({ months: 2 });
// Relative time
now.toRelative(); // 'in 2 hours'
// date-fns Examples
import { format, parseISO, addDays, differenceInDays } from 'date-fns';
import { formatInTimeZone } from 'date-fns-tz';
// Create dates
const now = new Date();
const specific = parseISO('2024-12-31');
// Format dates
format(now, 'dd/MM/yyyy'); // 31/12/2024
format(now, 'yyyy-MM-dd'); // 2024-12-31
// Time zones
formatInTimeZone(now, 'America/New_York', 'yyyy-MM-dd HH:mm:ss');
// Manipulation
addDays(now, 7);
subMonths(now, 2);
// Comparisons
differenceInDays(date1, date2);
isAfter(date1, date2);
// Day.js Examples
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc);
dayjs.extend(timezone);
// Create dates
const now = dayjs();
const specific = dayjs('2024-12-31');
// Format dates
now.format('DD/MM/YYYY'); // 31/12/2024
now.format('YYYY-MM-DD'); // 2024-12-31
// Time zones
now.tz('America/New_York');
// Manipulation
now.add(7, 'day');
now.subtract(2, 'month');
// Relative time
now.fromNow(); // 'in 2 hours'
// Moment.js Examples (Legacy - Not Recommended)
import moment from 'moment-timezone';
// Create dates
const now = moment();
const specific = moment('2024-12-31');
// Format dates
now.format('DD/MM/YYYY'); // 31/12/2024
now.format('YYYY-MM-DD'); // 2024-12-31
// Time zones
now.tz('America/New_York');
// Manipulation (mutates original!)
now.add(7, 'days');
now.subtract(2, 'months');
// Relative time
now.fromNow(); // 'in 2 hours'
Common questions when choosing a date library.
No. Moment.js is in maintenance mode and the team recommends using alternatives. It has a large bundle size, is mutable (error-prone), and doesn't support tree-shaking. Migrate to Luxon, Day.js, or date-fns.
Day.js at ~2KB is the smallest. date-fns can be even smaller if you only import what you need (tree-shaking). Choose based on your needs: Day.js for simplicity, date-fns for flexibility.
Luxon has the best time zone support using the Intl API. For date-fns, use the date-fns-tz extension. Day.js requires the timezone plugin. All rely on the browser's IANA time zone database.
For simple use cases, the native Date object may suffice. Use libraries when you need: time zones, complex formatting, date arithmetic, parsing multiple formats, or i18n. The upcoming Temporal API may reduce the need for libraries.
Temporal is a Stage 3 TC39 proposal to add a modern date/time API to JavaScript. It will likely become standard, but adoption will take years. Polyfills are available, but add significant bundle size. For now, stick with established libraries.
All modern libraries (Luxon, date-fns, Day.js, js-joda) have excellent TypeScript support with type definitions. Moment.js also has types but is no longer recommended.