Moment js convert milliseconds into date and time

前端 未结 2 1339
天涯浪人
天涯浪人 2021-02-01 12:49

I have current time in milliseconds as - 1454521239279

How do I convert it to 03 FEB 2016 and time as 11:10 PM ?

相关标签:
2条回答
  • 2021-02-01 12:56

    Moment parser

    moment(1454521239279).format("DD MMM YYYY hh:mm a") //parse integer
    moment("1454521239279", "x").format("DD MMM YYYY hh:mm a") //parse string
    

    Moment unix method

    moment.unix(1454521239279/1000).format("DD MMM YYYY hh:mm a")
    
    0 讨论(0)
  • 2021-02-01 13:10

    If you have 1o digit 1591074937 then you can convert like this.

    moment(1591074937*1000).format("DD MMM YYYY")
    
    OR
    
    new Date(1591074937 * 1000)
    
    0 讨论(0)
提交回复
热议问题