// 工夫戳 13 位
formatDate: function (time) {// 工夫戳转日期
let date = new Date(time);
let y = date.getFullYear();
let MM = date.getMonth() + 1;
MM = MM < 10 ? ('0' + MM) : MM;
let d = date.getDate();
d = d < 10 ? ('0' + d) : d;
let h = date.getHours();
h = h < 10 ? ('0' + h) : h;
let m = date.getMinutes();
m = m < 10 ? ('0' + m) : m;
let s = date.getSeconds();
s = s < 10 ? ('0' + s) : s;
return y + '-' + MM + '-' + d + '' + h +':'+ m +':' + s;
// return y + '-' + MM + '-' + d;
},
// 工夫戳 10 位
formatDate: function (time) {// 工夫戳转日期
let date = new Date(parseInt(time) * 1000);
let y = date.getFullYear();
let MM = date.getMonth() + 1;
MM = MM < 10 ? ('0' + MM) : MM;
let d = date.getDate();
d = d < 10 ? ('0' + d) : d;
let h = date.getHours();
h = h < 10 ? ('0' + h) : h;
let m = date.getMinutes();
m = m < 10 ? ('0' + m) : m;
let s = date.getSeconds();
s = s < 10 ? ('0' + s) : s;
return y + '-' + MM + '-' + d + '' + h +':'+ m +':' + s;
// return y + '-' + MM + '-' + d;
},
var times = Date.parse(new Date());// 不举荐应用,因为毫秒级别的数值被转化为 000,不精确!var times = (new Date()).valueOf();// 获取以后毫秒的工夫戳,精确!var times = new Date().getTime();// 返回数值单位是毫秒;
(new Date(this.zzsj)).getTime() //getTime() 返回数值的单位是毫秒
Date.parse()// 转工夫戳
getDatetime(){
// 获取以后的年月日
let date_ = new Date();
let seperator1 = "-";
let year = date_.getFullYear();
let month = date_.getMonth() + 1;
let strDate = date_.getDate();}