Angular 2 show current formatted date

前端 未结 3 735

I have the following code to show the current date:

this.whatTime = Observable.interval(1000).map(x => new Date()).share();

And in my te

3条回答
  •  旧时难觅i
    2020-12-19 17:49

    You should use this:

    import moment from 'moment';
    

    Then you should call it like that:

    moment(timestamp).fromNow();
    

    This will give you the current time.

提交回复
热议问题