How to return the current timestamp with Moment.js?

前端 未结 11 1661
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-23 00:28

Folks,

I am trying to understand the MomentJS API. What is the appropriate way to get the current time on the machine?

var CurrentDate = moment();
<         


        
11条回答
  •  醉梦人生
    2020-12-23 00:59

    I would like to add that you can have the whole data information in an object with:

    const today = moment().toObject();
    

    You should obtain an object with this properties:

    today: {
        date: 15,
        hours: 1,
        milliseconds: 927,
        minutes: 59,
        months: 4,
        seconds: 43,
        years: 2019
        }
    

    It is very useful when you have to calculate dates.

提交回复
热议问题