Question

I would like to use moment.js for date conversion.

Here's what I want:

var original_format = "Tuesday, May 22, 2012";

var output1 = "16 hours ago"
var output2 = "2012-05-22T00:00:00+02:00"

For the output1 no problem, for the second-one would it be possible to make it using moment.js?

moment("original_format").fromNow(); // "16 hours ago"
Était-ce utile?

La solution

moment("original_format").format();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top