Kevin Brown
Kevin Brown

Reputation: 12650

Date.js vs Moment.js (and server-side formatting)

I've been using Date.js in my project and recently read a post that moment.js was superior.

However, I'm having trouble believing that it is simply due to the fact that it can't parse input like "5 days from now" to an n actual date.

My personal desire/requirements are that

  1. I can take a variety of inputs (text-fields) and submit them as properly formatted dates.
  2. I can take properly formatted dates and output them as friendly (or just parse them differently).

Date.js does both. Moment.js seems to only do #2...

Am I missing something, or am I cool to use Date.js still?

Additionally...for my rails project. Is it better to format things server-side or client side? ie. I have a few things I'd like to format based on the relative date condition. (Like add a class if it's 10 days from now, or >0 days past now)...pros/cons of client/server side date parsing/manipulation?

Upvotes: 10

Views: 6632

Answers (2)

Yevgeniy Afanasyev
Yevgeniy Afanasyev

Reputation: 41350

It has been 8 years since the question asked. The situation has changed a bit.

momentjs has a web site and github has changes from (Oct 6, 2020). It has a sort of active development stage, when the original Datejs repository has been archived by the owner. Now there is DateJS: Evolved project form abritinthebay that has the latest changes on (Dec 17, 2014)

Bottom line - momentjs is still alive, when Datejs is not.

Upvotes: 4

Johnny Guillen
Johnny Guillen

Reputation: 116

You are correct. Moment.JS does not handle #2 .... only Date.js does.

As for server vs client... I tend to unload calculations to the client unless I am building a mobile app. In the end let the application/project determine where computation should occur.

Upvotes: 7

Related Questions