Formatting and modifying JavaScript dates with date-fns

Marina Mosti on January 20, 2019

Date manipulation in JavaScript may seem like a daunting thing to accomplish. The native Date() object is not very novice friendly and it requires ... [Read Full]
markdown guide

If you've ever used something like PHP's date handling functions, JS is a huge let down in this area. Though I must admit I never got around to picking up a Date library. I built a small one to make some things easier, but now I know which ones to start using, thanks!


It's actually not huge at all, date-fns v2 introduces new lightFormat that supports most popular tokens and its size is only 887 B.


Vanilla JS lacks the comparable features PHP provides out of the box, or the features provided in these libraries. I actually wasn't referring to the file size either, my bad!


I also come from a PHP background, and yeah libraries like Carbon are a must-have, but Moment and Date-fns really fill in the blanks :)


I have used format() method for converting date from "YYYY-MM-DD" to "DD/MM/YYYY". But it didn't work. stackoverflow.com/q/57594076/9282474 - here you can see question from stackoverflow. I need help. Please let me know where I'm making mistake. I have used MomentJS in example given on stackoverflow but after reading your blog I tried your format() method of date-fns. But that didn't work.


I have question, the latest date-fns doesn't support CDN version anymore and how to convert the code for use for web purpose? I am new to JS.

code of conduct - report abuse