How to convert unix timestamp to calendar date moment.js

前端 未结 11 2016
遥遥无期
遥遥无期 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 21:57

    Might be a little late but for new issues like this I use this code:

    moment(timestamp, 'X').format('lll');
    

    You can change the format to match your needs and also add timezone like this:

    moment(timestamp, 'X').tz(timezone).format('lll');
    

提交回复
热议问题