用js将从后台得到的时间戳(毫秒数)转换为想要的日期格式

先重写Dated的toLocaleString方法:

Date.prototype.toLocaleString = function() {
          return this.getFullYear() + "/" + (this.getMonth() + 1) + "/" + this.getDate() + "/ " + this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds();
    };


假设时间毫米数是10000,
var time = new Date(10000);

timeStr = time.toLocaleString();

参考网址:

http://www.cnblogs.com/zhanghaoliang/p/5997619.html

http://blog.csdn.net/bangrenzhuce/article/details/53022894



原文地址:https://www.cnblogs.com/shubiao/p/6556353.html