How to convert unix timestamp to calendar date moment.js

前端 未结 11 2033
遥遥无期
遥遥无期 2020-12-22 21:36

I have a unix timestamp, and I\'m trying to convert it into a calendar date such as MM/DD/YYYY. So far, I have this:



        
11条回答
  •  不知归路
    2020-12-22 22:12

    Moment.js provides Localized formats which can be used.

    Here is an example:

    const moment = require('moment');
    
    const timestamp = 1519482900000;
    const formatted = moment(timestamp).format('L');
    
    console.log(formatted); // "02/24/2018"
    

提交回复
热议问题