Javascript library that manipulates dates like Carbon?

Rohan picture Rohan · May 8, 2015 · Viewed 9.7k times · Source

I am working with Laravel since a while now and I am in love with the Carbon time stamp instances and how easy it is to manipulate them and convert them to human readable dates to display.

But right now I am working on a project where the front end is completely decoupled from the back end and I cannot call the Carbon API methods to convert the date into human readable format.

Is there a Javascript library which does the same manipulations like Carbon so that I can use it in front end templates and inject the human readable time formats into my views.

Answer

miensol picture miensol · May 8, 2015

You should definitely look at

moment.js

It provides a clear and nice to use interface i.e.:

var start = moment([2007, 0, 5]);
var end   = moment([2007, 0, 10]);
end.from(start);       // "in 5 days"
end.from(start, true); // "5 days"