DEV Community

Discussion on: date-fns: a moment.js alternative

Collapse
 
dollier profile image
Dorian C

I recently change one of my project using moment with dayjs and it was a breeze. I basically changed all moment() in dayjs() and it worked (expect for weekShortDays and weekdays in my experience), and it's 2kb. I'd love to hear your opinion on the two different libraries and why you choose date-fns, since I'm still in the process of choosing a library.

Collapse
 
idoshamun profile image
Ido Shamun

Honestly, I don't like that I have to create a custom object like in moment or dayjs (as you shown) to use the library. I prefer a set of functions that I can immediately apply on every date object.
This is exactly date-fns approach. They provide you functions not objects.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

Only that there is no piping in JavaScript (I think).

Thread Thread
 
idoshamun profile image
Ido Shamun

What do you mean?

Thread Thread
 
patarapolw profile image
Pacharapol Withayasakpunt

|> or %>%. I know it is only for the sake of convenience, though.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

Now, I have to wonder. Is JavaScript Date object good enough?

Can it validate 2020-13-32, or is it browser dependent?

stackoverflow.com/questions/744532...