DEV Community

Cover image for Day.js | The lightest API to handle dates in JS

Day.js | The lightest API to handle dates in JS

Jesús Mejías Leiva on September 14, 2021

Today I am writing again to bring you a library that will help us with the handling of dates in JavaScript, yes, as we all know the handling of dat...
Collapse
 
fabian3081 profile image
Fabian Scharfenberger

Didn't heared of day.js before. Looks as light as you said.
Thanks, I'll keep it in mind for my future projects.

Collapse
 
susomejias profile image
Jesús Mejías Leiva

Thank you for your comment, I am glad that it is useful to you 🤗

Collapse
 
rcoundon profile image
Ross Coundon

It's nice to use but there's an outstanding issue in dealing with Daylight Savings Time raised a few months ago which meant we had to move to a different library. We now use Luxon, which works very well.

Collapse
 
susomejias profile image
Jesús Mejías Leiva • Edited

Oh thanks for your contribution 🎉 i was unaware of this topic 🙈

Collapse
 
rcoundon profile image
Ross Coundon

No problem, it's this one
github.com/iamkun/dayjs/issues/1260
but I see there have been a lot of similar issues raised since

Collapse
 
gerreth profile image
Gerret Halberstadt

I was quite happy with dayjs until I had to deal with issues with different timezones and DST. We started to migrate to luxon and luckily the API is mostly the same. I'd strongly recommend to consider this in your decision to use dayjs as it could help you from some hard to spot bugs.

Collapse
 
susomejias profile image
Jesús Mejías Leiva

Thank you for your contribution! 🤗

Collapse
 
pawelmiczka profile image
Paweł Miczka

Isn't date-fns better? I didn't tested it out but I think that dayjs will include whole library in production build. In the other hand date-fns has is tree shakable.

Collapse
 
susomejias profile image
Jesús Mejías Leiva • Edited

Dayjs also supports tree-shaking, although date-fns is another great library for handling dates in JavaScript 🤗

Collapse
 
vulchivijay profile image
Vijaya Kumar

We can write our own right.

Collapse
 
smhz101 profile image
Muzammil Hussain

It seems amazing, i'll definitely use in my next project. Thanks for sharing...

Collapse
 
susomejias profile image
Jesús Mejías Leiva

Thanks to you for your comment, good luck with that next project 😜