Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
dayjs vs luxon vs js-joda vs date-fns (comparing)
(version: 3)
Comparing performance of:
Dayjs vs luxon vs js-joda vs date-fns
Created:
2 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/dayjs@1.11.9/dayjs.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@3.4.3/build/global/luxon.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@js-joda/core@5.5.3/dist/js-joda.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.9.0/date_fns.min.js"></script>
Script Preparation code:
var dayjsDate1 = dayjs('2022-09-01T00:00:00+09:00'); var dayjsDate2 = dayjs('2023-09-01T00:00:00+09:00'); var luxonDate1 = luxon.DateTime.fromISO("2022-09-01T00:00:00+09:00"); var luxonDate2 = luxon.DateTime.fromISO("2023-09-01T00:00:00+09:00"); var jsJodaDate1 = JSJoda.ZonedDateTime.parse('2022-09-01T00:00:00+09:00', JSJoda.DateTimeFormatter.ISO_OFFSET_DATE_TIME); var jsJodaDate2 = JSJoda.ZonedDateTime.parse('2023-09-01T00:00:00+09:00', JSJoda.DateTimeFormatter.ISO_OFFSET_DATE_TIME); var date1 = new Date('2022-09-01T00:00:00+09:00'); var date2 = new Date('2023-09-01T00:00:00+09:00');
Tests:
Dayjs
dayjsDate1.isBefore(dayjsDate2);
luxon
luxonDate1 < luxonDate2
js-joda
jsJodaDate1.isBefore(jsJodaDate2);
date-fns
dateFns.isBefore(date1, date2);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Dayjs
luxon
js-joda
date-fns
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Dayjs
2431580.0 Ops/sec
luxon
9240845.0 Ops/sec
js-joda
23913684.0 Ops/sec
date-fns
17986768.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down what's being tested in this benchmark. **Benchmark Definition** The benchmark is comparing the performance of four date and time libraries: Dayjs, Luxon, js-joda, and date-fns. The comparison is done by performing a simple "is before" check on two dates. **Options Compared** Each library has its own way of representing and manipulating dates: 1. **Dayjs**: A lightweight, JavaScript-only library that provides a modern alternative to the traditional Date class. 2. **Luxon**: A powerful, modern date and time library developed by the same team as Moment.js. It's designed for performance and ease of use. 3. **js-joda**: A Java-based library (not specifically designed for JavaScript) that uses the Joda-Time API. It's been ported to JavaScript, but it may not be as efficient or easy to use as the other options. 4. **date-fns**: A smaller, more lightweight library developed by Dan Abramov. It provides a simple and intuitive API for working with dates. **Pros and Cons of Each Approach** 1. **Dayjs**: * Pros: Lightweight, easy to use, fast execution times. * Cons: May not be as robust or feature-rich as other libraries. 2. **Luxon**: * Pros: Modern, powerful API, excellent performance, support for various date formats and timezones. * Cons: Larger library size compared to Dayjs, may require more setup. 3. **js-joda**: * Pros: Robust, feature-rich API (thanks to its Joda-Time roots), fast execution times. * Cons: May be harder to learn and use due to its Java-based origins, larger library size. 4. **date-fns**: * Pros: Lightweight, easy to use, simple and intuitive API. * Cons: Limited features compared to the other options. **Special JS Features or Syntax** None are explicitly mentioned in this benchmark. **Library Descriptions** 1. **Dayjs**: A JavaScript-only library that provides a modern alternative to traditional Date objects. It's designed for performance and ease of use, with features like automatic timezone detection and support for various date formats. 2. **Luxon**: A powerful, modern date and time library developed by the Moment.js team. It provides an excellent API for working with dates, including support for various date formats, timezones, and date arithmetic. 3. **js-joda**: A Java-based library (not specifically designed for JavaScript) that uses the Joda-Time API. It's been ported to JavaScript, but it may not be as efficient or easy to use as the other options. 4. **date-fns**: A lightweight, JavaScript-only library developed by Dan Abramov. It provides a simple and intuitive API for working with dates, including support for various date formats and date arithmetic. **Alternatives** If you're looking for alternative libraries, some options include: 1. **Moment.js**: A popular JavaScript library for working with dates and times (although it's been somewhat overshadowed by Dayjs and Luxon). 2. **Date-fiddle**: A lightweight, simple library that provides a basic API for working with dates. 3. **date-parser**: A library specifically designed for parsing date strings. Keep in mind that the choice of library ultimately depends on your specific use case and performance requirements.
Related benchmarks:
luxon.fromSeconds(seconds) vs Date(seconds * 1000)
dayjs vs luxon vs js-joda vs date-fns (formatting)
dayjs vs luxon vs js-joda vs date-fns (manipulating)
dayjs vs luxon vs js-joda vs date-fns (calculating)
Comments
Confirm delete:
Do you really want to delete benchmark?