Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

js时间戳转换成日期的方法

时间戳好像是13位的纯数字。
如:1596297600000
我只需要年月日。
显示在elementui的日期组件那种格式image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

已解决

    //时间戳转换方法    time:需要被转换的时间戳数字
    formatDate(time) {
      var date=new Date(parseInt(time));
      var year=date.getFullYear();
      var mon = date.getMonth()+1;
      var day = date.getDate();
      return year+'/'+mon+'/'+day;
    },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...