Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Modern Date Libraries
(version: 0)
Comparing performance of:
Luxon vs Date-fns vs Dayjs
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/2.0.0-alpha0/date_fns.min.js" integrity="sha512-0kon+2zxkK5yhflwFqaTaIhLVDKGVH0YH/jm8P8Bab/4EOgC/n7gWyy7WE4EXrfPOVDeNdaebiAng0nsfeFd9A==" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.25.0/build/global/luxon.min.js"></script> <script src="https://unpkg.com/dayjs@1.8.21/dayjs.min.js"></script>
Script Preparation code:
window.__date__ = new Date(); window.__expected__ = '2000/01/06';
Tests:
Luxon
var actual = luxon.DateTime.fromJSDate(__date__).toFormat('yyyy/MM/dd'); console.assert(actual === __expected__);
Date-fns
var actual = dateFns.format(__date__, 'YYYY/MM/DD'); console.assert(actual === __expected__);
Dayjs
var actual = dayjs(__date__).format('YYYY/MM/DD'); console.assert(actual === __expected__);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Luxon
Date-fns
Dayjs
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser/OS:
Chrome 138 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Luxon
215277.7 Ops/sec
Date-fns
261287.3 Ops/sec
Dayjs
108115.3 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Measuring JavaScript performance is crucial for modern web development. MeasurThat.net provides an excellent platform to compare the performance of various date and time libraries. **What's being tested?** In this benchmark, three popular JavaScript libraries are compared: 1. **Date-fns**: A lightweight and versatile library for date and time manipulation. 2. **Luxon**: A modern and powerful library developed by the same team behind Moment.js (although it's not a direct replacement). 3. **Dayjs**: A fast and flexible alternative to Date.js. The benchmark focuses on converting a JavaScript `Date` object to a string representation in the format "YYYY/MM/DD" using each library. **Options compared** Each library offers different approaches to achieve this conversion: 1. **Date-fns**: Uses its `format()` function, which takes an options object and returns the formatted date string. 2. **Luxon**: Utilizes its `DateTime` class, specifically the `toFormat()` method, which formats a `DateTime` object as a string. 3. **Dayjs**: Employs its `format()` function, similar to Date-fns. **Pros and cons of each approach** 1. **Date-fns**: * Pros: Lightweight ( around 10KB gzipped), simple API, fast performance. * Cons: Limited features compared to other libraries. 2. **Luxon**: * Pros: Feature-rich, modern architecture, excellent support for internationalization and time zones. * Cons: Heavier than Date-fns (~30KB gzipped) due to its more comprehensive feature set. 3. **Dayjs**: * Pros: Extremely lightweight (around 2KB gzipped), fast performance, simple API. * Cons: Limited features compared to Luxon and Date-fns. **Library libraries** 1. **Date-fns**: A small, modular library designed for date and time manipulation. It provides an extensive set of functions for various tasks, such as formatting dates, calculating durations, and handling time zones. 2. **Luxon**: Developed by the same team behind Moment.js, Luxon is a modern alternative to traditional date libraries. It offers advanced features like support for internationalization, time zones, and precision arithmetic. **Special JS features or syntax** None are explicitly mentioned in this benchmark. **Other alternatives** If you're considering alternative JavaScript date and time libraries, some notable options include: 1. **Moment.js**: A widely used library with a comprehensive set of features. 2. **Date.js**: An older but still maintained library, often considered as an alternative to Date-fns. 3. **Moment-Time-Zone (MTZ)**: An extension of Moment.js for handling time zones. When choosing a JavaScript date and time library, consider factors such as performance, feature set, internationalization support, and ease of use for your specific project needs.
Related benchmarks:
date formatter libraries
date format
luxon vs datefns vs moment vs dayjs
luxon vs datefns vs moment vs day.js
Comments
Confirm delete:
Do you really want to delete benchmark?