문제

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