Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Date libraries benchmark JS 1
(version: 1)
Comparing performance of:
luxon vs date-fns vs dayjs vs js-joda
Created:
3 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/luxon@3.2.1/build/global/luxon.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@js-joda/core@5.5.2/dist/js-joda.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/2.0.0-alpha0/date_fns.min.js"></script> <script src="https://unpkg.com/dayjs@1.11.7/dayjs.min.js"></script> <script src="https://unpkg.com/dayjs@1.11.7/plugin/isBetween.js"></script> <script src="https://wzrd.in/standalone/dateformat@latest"></script>
Script Preparation code:
dayjs.extend(window.dayjs_plugin_isBetween) window.__date__ = new Date('2000-01-06T03:24:11'); window.__another_date__ = new Date('2000-01-30T03:24:11'); window.__another_month__ = new Date('2000-02-01T00:00:00'); window.__another_year__ = new Date('1999-01-06T03:24:11'); window.__saturday__ = new Date('2021-05-01T03:24:11'); window.__sunday__ = new Date('2021-05-02T03:24:11'); window._expected_string = '2000/01/06'; window._expected_start = '2000/01/01'; window._expected_end = '2000/01/31'; window._expected_day_of_week = 1;
Tests:
luxon
var actual = luxon.DateTime.fromJSDate(__date__); console.assert(actual.toFormat('yyyy/MM/dd') === _expected_string); var start = actual.startOf('month'); console.assert(start.toFormat('yyyy/MM/dd') === _expected_start); var end = actual.endOf('month'); console.assert(end.toFormat('yyyy/MM/dd') === _expected_end); var i = luxon.Interval.fromDateTimes(start, end); var isBefore = luxon.DateTime.fromJSDate(__another_date__) < end; console.assert(isBefore === true); var isBetween = i.contains(actual); console.assert(isBetween === true); var isInclusive = i.contains(start); console.assert(isInclusive === true); console.assert(luxon.DateTime.fromJSDate(__saturday__).weekday === 6); console.assert(start.hasSame(end, 'month') === true); console.assert(luxon.DateTime.fromJSDate(__another_month__).hasSame(end, 'month') === false); console.assert(luxon.DateTime.fromJSDate(__another_year__).hasSame(actual, 'month') === false); console.assert(luxon.DateTime.fromJSDate(__sunday__).daysInMonth === 31);
date-fns
var actual = __date__; console.assert(dateFns.format(actual, 'YYYY/MM/DD') === _expected_string); var start = dateFns.startOfMonth(actual); console.assert(dateFns.format(start, 'YYYY/MM/DD') === _expected_start); var end = dateFns.endOfMonth(actual); console.assert(dateFns.format(end, 'YYYY/MM/DD') === _expected_end); var isBetween = dateFns.isWithinRange(actual, start, end); console.assert(isBetween === true); var isInclusive = dateFns.isWithinRange(start, start, end); console.assert(isInclusive === true); console.assert(dateFns.isSaturday(__saturday__) === true); console.assert(dateFns.isSameMonth(start, end) === true); console.assert(dateFns.isSameMonth(__another_month__, end) === false); console.assert(dateFns.isSameMonth(__another_year__, actual) === false); console.assert(dateFns.getDaysInMonth(__sunday__) === 31);
dayjs
var actual = dayjs(__date__); console.assert(actual.format('YYYY/MM/DD') === _expected_string); var start = actual.startOf('month'); console.assert(start.format('YYYY/MM/DD') === _expected_start); var end = actual.endOf('month'); console.assert(end.format('YYYY/MM/DD') === _expected_end); var isBetween = actual.isBetween(start, end); console.assert(isBetween === true); var isInclusive = start.isBetween(start, end, 'day', '[]'); console.assert(isInclusive === true); console.assert(dayjs(__saturday__).day() === 6); console.assert(start.isSame(end, 'month') === true); console.assert(dayjs(__another_month__).isSame(end, 'month') === false); console.assert(dayjs(__another_year__).isSame(actual, 'month') === false); console.assert(dayjs(__sunday__).daysInMonth() === 31);
js-joda
var actual = JSJoda.LocalDate.from(JSJoda.nativeJs(__date__)); console.assert(actual.format(JSJoda.DateTimeFormatter.ofPattern('yyyy/MM/dd')) === _expected_string); var start = actual.with(JSJoda.TemporalAdjusters.firstDayOfMonth()); console.assert(start.format(JSJoda.DateTimeFormatter.ofPattern('yyyy/MM/dd')) === _expected_start); var end = actual.with(JSJoda.TemporalAdjusters.lastDayOfMonth()); console.assert(end.format(JSJoda.DateTimeFormatter.ofPattern('yyyy/MM/dd')) === _expected_end); var isBetween = actual.compareTo(start) >= 0 && actual.compareTo(end) <= 0; console.assert(isBetween === true); var isInclusive = start.compareTo(start) >= 0 && start.compareTo(end) <= 0; console.assert(isInclusive === true); console.assert(JSJoda.LocalDate.from(JSJoda.nativeJs(__saturday__)).dayOfWeek() === JSJoda.DayOfWeek.SATURDAY); console.assert(start.withDayOfMonth(1).equals(end.withDayOfMonth(1))); console.assert(JSJoda.LocalDate.from(JSJoda.nativeJs(__another_month__)).withDayOfMonth(1).equals(end.withDayOfMonth(1)) === false); console.assert(JSJoda.LocalDate.from(JSJoda.nativeJs(__another_year__)).withDayOfMonth(1).equals(actual.withDayOfMonth(1)) === false); console.assert(JSJoda.LocalDate.from(JSJoda.nativeJs(__sunday__)).lengthOfMonth() === 31);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
luxon
date-fns
dayjs
js-joda
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It seems like you're describing the results of benchmarking different date and time libraries. To answer your question, it appears that the results show that: 1. **js-joda**: has the fastest execution speed with an average of 37777 executions per second. 2. **date-fns**: is a close second with an average of 33490 executions per second. 3. **dayjs**: falls behind both js-joda and date-fns, but still performs well with an average of 10123 executions per second. 4. **luxon**: has the slowest execution speed with an average of 7075 executions per second. These results suggest that **js-joda** is currently the fastest JavaScript library for working with dates and times.
Related benchmarks:
JS Date libraries 2
Dayjs Date-fns format comparison 6
JS Date libraries 2023.0
JS Date libraries 2 fixed
Comments
Confirm delete:
Do you really want to delete benchmark?