JavaScript date libraries

Updated Nov 2026

JavaScript date libraries parse, format, and calculate with dates beyond what the built-in Date object offers. These libraries handle the schedules, billing periods, and user-entered dates that web apps track across time zones.

Popularity

date-fns has the most monthly downloads in this comparison, at 466.2M.

LibraryMonthly downloadsStarsLast releaseLicense
date-fns
469.0M
36.7KMay 2026MIT
Day.js
422.6M
48.6KAug 2026MIT
d3-time
393.8M
237Nov 2026ISC
Luxon
226.8M
16.5KSep 2025MIT
Moment.js
199.0M
47.9KSep 2026MIT
dateformat
173.7M
1.3KOct 2026MIT
Fecha
136.2M
2.1KApr 2022MIT
@internationalized/date
99.3M
16.1KSep 2026Apache-2.0
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

date-fns is a set of functions for the built-in Date object, in the browser and in Node.js. Each function takes a Date and returns a new one, so the input never changes, and the library never adds methods to Date itself. format turns a date into text from a pattern of Unicode tokens, and compareAsc orders dates for sorting. Every function imports on its own, so a bundler keeps only the functions an app calls. Calculations in a named time zone come from the separate @date-fns/tz package.

Downloads / mo
469.0M
Stars
36.7K
Last release
4.4.0
License
MIT

Strengths

  • Takes native Date values. Use date helpers without converting values into a wrapper object.
  • Supports selective imports. Import the helpers and locales that the application needs.

Limitations

  • Time zones need another package. Install @date-fns/tz for calculations in a selected time zone.
  • Format tokens differ from Moment. format and parse use Unicode tokens, so a Moment string such as YYYY-MM-DD becomes yyyy-MM-dd.

Quickstart

From README.md
$ npm install date-fns
import { compareAsc, format } from "date-fns";

format(new Date(2014, 1, 11), "yyyy-MM-dd");

date-fns examples

From open-source projects on GitHub
const isStrictValidDate = (text: string, format: string, locale: string) => {
  const date = parse(text, format, locale);
  if (!isValid(date)) {
    return false;
  }
  const formattedDate = formatDate(date, format, { locale: getLocale(locale) });
  return text === formattedDate;
}

Day.js parses, validates, changes, and formats dates through an API that is largely compatible with Moment.js. A call to dayjs() wraps a date in a Day.js object, and methods such as add, startOf, and format chain onto it. Every change returns a new object rather than editing the existing one. Locales and extra features load as plugins through dayjs.extend, and only the ones an app imports reach its bundle. Parsing a custom format and converting between named time zones both come from plugins.

Downloads / mo
422.6M
Stars
48.6K
Last release
1.11.23
License
MIT

Strengths

  • Follows the Moment.js API. Chain parsing, date changes, and formatting through a similar API.
  • Keeps date operations immutable. Receive a new Day.js instance when changing a date.

Limitations

  • Strict validation needs a plugin. Enable CustomParseFormat and pass the input format plus strict flag.
  • Default zone reaches tz calls only. dayjs() keeps the local time zone after dayjs.tz.setDefault; only dayjs.tz() reads the default.

Quickstart

From node-js.md
$ npm install dayjs
const dayjs = require('dayjs')
//import dayjs from 'dayjs' // ES 2015
dayjs().format()

Day.js examples

From open-source projects on GitHub

d3-time does calendar math on top of the built-in Date. It rounds a date to a boundary, counts the boundaries between two dates, and lists them. Each interval, such as day, week, or month, has floor, ceil, count, and range methods. Counting days with the day interval stays correct across a daylight saving change, where subtracting timestamps and dividing by the length of a day gives a fraction. The module has no calendar system of its own and ignores leap seconds. Formatting and parsing live in a separate time format module.

Downloads / mo
393.8M
Stars
237
Last release
3.1.1
License
ISC

Limitations

  • Local time and UTC only. Intervals work in the local time zone and UTC, with no named time zones.

Quickstart

From time docs
$ npm install d3-time
import { timeDay } from "d3-time";

const start = new Date(2015, 2, 1);
const end = new Date(2015, 3, 1);
console.log(timeDay.count(start, end));

d3-time examples

From open-source projects on GitHub
export function localISOWeekYear(d) {
  return timeDay.offset(timeMonday.floor(d), 3).getFullYear();
}

Luxon represents time with three immutable types of its own: DateTime for a moment, Duration for a length of time, and Interval for the span between two moments. Methods chain, so DateTime.now().setZone('America/New_York') moves the current time into that zone and later calls build on the result. Time zones and locales come from the runtime's Intl API, so the package ships no zone or locale files. DateTime.fromFormat parses text against a custom format, and toISO writes a DateTime back out as an ISO string.

Downloads / mo
226.8M
Stars
16.5K
Last release
3.7.2
License
MIT

Strengths

  • Includes duration and interval types. Represent elapsed spans and intervals alongside DateTime values.
  • Uses native locale and zones. Use the runtime’s Intl data instead of shipping separate locale files.

Limitations

  • Custom parsing matches formats strictly. DateTime.fromFormat accepts only text that matches the format exactly.
  • Locale parsing depends on Intl. Locale-specific format strings come from the runtime's Intl data and can differ between environments.

Quickstart

From install.md
$ npm install luxon
import { DateTime } from "luxon";

console.log(DateTime.now().toISO());

Luxon examples

From open-source projects on GitHub
(locale, date, format) => {
      if (!date || !date.isValid) {
        return null;
      }

      return date.setLocale(normalizeLocale(locale)).toFormat(normalizeFormat(format));
    }

Moment.js parses, validates, changes, and formats dates through a moment object that wraps a Date. It runs in browsers and in Node.js. Format strings use tokens such as YYYY-MM-DD, and parsing accepts a format and a locale. Named time zones come from the separate moment-timezone package and its zone data. The project is in maintenance mode and accepts no new features.

Downloads / mo
199.0M
Stars
47.9K
Last release
2.31.0
License
MIT

Limitations

  • In maintenance mode. The project accepts no new features. Named time zones need the separate moment-timezone package.

Quickstart

From node-js.md
$ npm install moment
const moment = require('moment');

moment().format();

Moment.js examples

From open-source projects on GitHub
(date) => {
    const clone = date.clone().locale('en_US');
    return clone.weekday() + clone.localeData().firstDayOfWeek();
  }

dateformat turns a Date into text from a mask, a pattern of letters such as dddd, mmmm dS, yyyy. Named masks cover common layouts, among them isoDateTime and fullDate, and new ones can be added to the exported masks object. Passing true as a third argument, or starting a mask with UTC:, prints the time in UTC. The package formats only and has no function for parsing text back into a Date. It also installs a dateformat command for the terminal.

Downloads / mo
173.7M
Stars
1.3K
Last release
5.0.5
License
MIT

Quickstart

From Readme.md
$ npm install dateformat
import dateFormat, { masks } from "dateformat";
const now = new Date();

// Basic usage
dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");

dateformat examples

From open-source projects on GitHub
function timestamp () {
  let date = new Date();
  if (!timeZone) {
    date = new Date(date.valueOf() + date.getTimezoneOffset() * 60000);
  }
  return dateformat(date, "yyyy-mm-dd HH:MM:ss:l");
}

Fecha formats and parses dates and leaves out date arithmetic, as a replacement for the formatting and parsing parts of Moment.js. format takes a Date or a timestamp and a format string such as dddd MMMM Do, YYYY, and returns text. Named formats such as isoDate and mediumDate are built in. parse reads a string against a required format and returns a Date or null.

Downloads / mo
136.2M
Stars
2.1K
Last release
4.2.3
License
MIT

Limitations

  • No date arithmetic. Fecha formats and parses only; adding or subtracting time needs another library.

Quickstart

From README.md
$ npm install fecha
import { format } from 'fecha';

format(new Date(2015, 10, 20), 'dddd MMMM Do, YYYY'); // 'Friday November 20th, 2015'

Fecha examples

From open-source projects on GitHub

@internationalized/date

@internationalized/date represents dates and times with immutable objects tied to a calendar system. CalendarDate holds a date with no time, CalendarDateTime adds a time without a zone, and ZonedDateTime holds a date and time in a specific time zone. The package supports thirteen calendar systems, including Gregorian, Buddhist, Islamic, and Persian, and converts values between calendars, time zones, and strings. Operations that could be ambiguous, such as arithmetic across a daylight saving change, resolve the ambiguity explicitly. The design follows Temporal, the date API proposed for JavaScript itself.

Downloads / mo
99.3M
Stars
16.1K
Last release
3.12.4
License
Apache-2.0

Quickstart

From README.md
$ npm install @internationalized/date
import {CalendarDate, startOfWeek} from '@internationalized/date';

let date = new CalendarDate(2022, 2, 3);
date = date.add({weeks: 1});
date = startOfWeek(date, 'en-US');
date.toString(); // 2022-02-06

@internationalized/date examples

From open-source projects on GitHub
function createRegex(locale: string, timeZone: string) {
  const formatter = new DateFormatter(locale, { day: "numeric", month: "numeric", year: "numeric", timeZone })
  const parts = formatter.formatToParts(new Date(2000, 11, 25))
  return parts.map(({ type, value }) => (type === "literal" ? `${value}?` : `((?!=<${type}>)\\d+)?`)).join("")
}

FAQ

For functions that work on native Date values, use date-fns. For a chainable API that matches Moment.js, use Day.js. For named time zones, durations, and intervals in the core package, use Luxon, and for calendars other than Gregorian, use @internationalized/date.

With date-fns, format(date, 'yyyy-MM-dd') returns the date as text in that pattern. Day.js chains the same step as dayjs(date).format('YYYY-MM-DD'). Without a library, Intl.DateTimeFormat formats a Date for a locale but takes no custom pattern.

Day.js wraps each date in its own object and chains methods in the style of Moment.js. date-fns is a set of separate functions that take and return native Date values, so a bundler keeps only the functions an app imports. Both return a new value instead of changing the original.

Luxon has its own DateTime, Duration, and Interval types and handles named time zones in the core package through the runtime's Intl API. date-fns works on native Date values and adds time zone calculations through the separate @date-fns/tz package.

Day.js copies most of the Moment.js API, so most Moment code reads the same. Day.js returns a new object on every change, and its locales and extra features load as plugins. Moment.js is in maintenance mode and accepts no new features.

Install @date-fns/tz. Its TZDate class extends Date and performs every calculation in a given time zone rather than the system zone, so date-fns functions accept it like any other Date.

For coding agents

Found your date library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official