Search code examples
javascriptdatetimephp-carbon

Javascript library that manipulates dates like Carbon?


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.


Solution

  • 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"