Ooooo boi! Did I just find something cool? Yes indeedy I did! If messing with dates in JavaScript gives you headaches like it does me, check out this library of absolute awesomeness:

Date-Fnshttps://date-fns.org/

With gems such as startOfHour(.), isToday(.)/isTomorrow(.), nextWednesday(.), isThisWeek(.), and many more, all the pain and suffering are taken out when messing with dates. Plus, you only import what you need, so it’s a lightweight library too.

Try it out!

Install: npm install date-fns

Import: import isThisWeek from 'date-fns/isThisWeek';

Use: console.log("Is today this week? " + isThisWeek(new Date()));

Have fun! 😁

Dates in JavaScript best library

You may also be interested in: this JavaScript tutorial


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *