时间戳转换成时分秒

 formatDate(date){
        date = new Date(date);
        var y=date.getFullYear();
        var m=date.getMonth()+1;
        var d=date.getDate();
        var h=date.getHours();
        var m1=date.getMinutes();
        var s=date.getSeconds();
        h = h<10?("0"+h):h;
        m1 = m1<10?("0"+m1):m1;
        s = s<10?("0"+s):s;
        m = m<10?("0"+m):m;
        d = d<10?("0"+d):d;
        return y+"-"+m+"-"+d + "   "+h+"-"+m
      },
 this.inform.forEach(function(val, idx, arr) {
                    var times= val.create_time
                var changesjc = new Date(times* 1000);//转换成普通日期格式
                var fk_time = that.formatDate(changesjc, 'yyyy年MM月dd日 hh:mm:ss');
                    val.create_time= fk_time
            })
发布了33 篇原创文章 · 获赞 0 · 访问量 3185

猜你喜欢

转载自blog.csdn.net/YYY1920/article/details/102622931