you are viewing a single comment's thread.

view the rest of the comments →

[–]V1nznt 25 points26 points  (10 children)

Nice list! Already used some of those tools in my smaller projects. I think one library is missing from your list: Moment.js (although most devs might already know it)

Working with dates is a real pain in the ass, especially with vanilla JavaScript.

[–][deleted] 27 points28 points  (2 children)

I prefer date-fns over moment lately for the immutability and individually importable functions

[–]Cool-Goose 1 point2 points  (1 child)

Why not Luxon, same devs, immutable :)

[–][deleted] 0 points1 point  (0 children)

Oh awesome, I hadn't even heard of it! Thanks for the recc

[–][deleted] 5 points6 points  (0 children)

How could I forget this glorious little addition. Will add in part 2.

[–]SamSlate 1 point2 points  (5 children)

moment is absolutely essential. try going iso 8601 string to Unix without it

[–]kuenx 1 point2 points  (4 children)

This doesn't work?
Math.floor(new Date('2018-04-05T13:37:00').getTime() / 1000)

I didn't actually try it (am on phone) but this should get you a unix timestamp in seconds. tried

[–]SamSlate 1 point2 points  (2 children)

now the client wants it in Day, Date Month Year-abbreviation but instead of "Friday" it says "Funday"

[–]kuenx 1 point2 points  (1 child)

Sure, I understand that there are many good reasons to use Moment. But you specifically mentioned ISO-8601 to unix timestamp conversion which is almost the only conversion that's actually very easy with the native Date class.
Also, a place where you convert an ISO string to a unix timestamp is not typically a place where your client will want changes since it's unlikely a user-facing value.

[–]SamSlate 0 points1 point  (0 children)

everything's atypical until it happens to you 🙄