How to return the current timestamp with Moment.js?

前端 未结 11 1751
佛祖请我去吃肉
佛祖请我去吃肉 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:47

    Try this way:

    console.log(moment().format('L'));
    moment().format('L');    // 05/25/2018
    moment().format('l');    // 5/25/2018
    

    Format Dates:

    moment().format('MMMM Do YYYY, h:mm:ss a'); // May 25th 2018, 2:02:13 pm
    moment().format('ffffdd');                    // Friday
    moment().format("MMM Do YY");               // May 25th 18
    moment().format('YYYY [escaped] YYYY');     // 2018 escaped 2018
    moment().format();                          // 2018-05-25T14:02:13-05:00
    

    Visit: https://momentjs.com/ for more info.

提交回复
热议问题