1、时间和毫秒数的转换
(1)、时间转换为毫秒数 +new Date(); (new Date()).getTime()
(2)、毫秒数转换为日期格式 new Date("134553244436")
2、时间格式的转换
var unixTime = new Date(); var userTime = new Date(45433565465); Date.prototype.layoutString = function() { return this.getFullYear() + "年" + (this.getMonth() + 1) + "月" + this.getDate() + "日 " + this.getHours() + "点" + this.getMinutes() + "分" + this.getSeconds() + "秒"; }; console.log(unixTime.layoutString()); console.log(userTime.layoutString());