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"
有帮助吗?

解决方案

moment("original_format").format();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top