Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
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.
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.
Libraries and code examples
date-fns
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.
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
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.
(locale, text, formats) => {
// Preserve Day.js fallback when the requested locale data is not registered. const localeStr = dayjs().locale(parseLocale(locale)).locale();
for (let i = 0; i < formats.length; i += 1) {
const format = formats[i];
const formatText = text;
if (format.includes('wo') || format.includes('Wo')) {
// parse Wo const year = formatText.split('-')[0];
const weekStr = formatText.split('-')[1];
const firstWeek = dayjs(year, 'YYYY').startOf('year').locale(localeStr);
for (let j = 0; j <= 52; j += 1) {
const nextWeek = firstWeek.add(j, 'week');
if (nextWeek.format('Wo') === weekStr) {
return nextWeek;
}
}
parseNoMatchNotice();
return null;
}
const date = dayjs(formatText, format, localeStr, true);
if (date.isValid()) {
return date;
}
}
if (text) {
parseNoMatchNotice();
}
return null;
}
d3-time
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.
export function localISOWeekYear(d) {
return timeDay.offset(timeMonday.floor(d), 3).getFullYear();
}
Luxon
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.
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.
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.
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
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.
parseDisabledDates() {
// Sort disabled dates and store it in property const _tmp = [];
this.setFechaI18n();
for (let i = 0; i < this.disabledDates.length; i++) {
_tmp[i] = fecha.parse(this.disabledDates[i], "YYYY-MM-DD");
}
_tmp.sort((a, b) => {
return a - b;
});
this.disabledDatesTime = _tmp;
}
@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.
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
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.