Format relative time in momentJs

后端 未结 4 2103
悲哀的现实
悲哀的现实 2020-12-09 22:08

If I use

moment().startOf(\"minute\").fromNow();

I will get:

a few seconds ago
a minute ago
...

Is it po

4条回答
  •  孤街浪徒
    2020-12-09 23:02

    You can use fromNow() method.

    moment(

    If you pass true, you can get the value without the suffix.

    moment([2007, 0, 29]).fromNow();     // 4 years ago
    moment([2007, 0, 29]).fromNow(true); // 4 years
    

    For more info you can refer source

提交回复
热议问题