How to return the current timestamp with Moment.js?

前端 未结 11 1731
佛祖请我去吃肉
佛祖请我去吃肉 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 00:35

    To use am / pm with moment, here is a snippet from a react component

    import Moment from 'moment';
    
    const time = Moment().format("hh:mm a")
    

    For reference please remember Moment.js is considered a legacy project that can carry performance overhead

提交回复
热议问题